My MSN

Click OK to add this content

 
Content Preview: rss
-+Unix Daemon Server Programming
438 days ago
Introduction Unix processes works either in foreground or background. A process running in foreground interacts with the user in front of the terminal (makes I/O), whereas a background process runs by itself. The user can check its status but he doesn't (need to) know what it is doing. The term 'daemon' is used for processes that performs service in background. A server is a process that begins execution at startup (not neccessarily), runs forever, usually do not die or get restarted, operates in background, waits for requests to arrive and respond to them and frequently spawn other processes to handle these requests. Readers are suppossed to know Unix fundamentals and C language. For further description on any topic use "man" command (I write useful keywords in brackets), it has always been very useful, trust me :)) Keep in mind that this document does not contain everything, it is just a guide. 1) Daemonizing (programming to operate in background) [fork] First the ...
-+C 语言参数读取代码
444 days ago
效果图 static struct option long_options[] = {     {"help", no_argument, NULL, 'h'},     {"tcp", required_argument, NULL, 't'},     {"udp", required_argument, NULL, 'u'},     {"ip", required_argument, NULL, 'i'},     {"ping", no_argument, NULL, 'p'},     {"size", required_argument, NULL, 's'},     {"count", required_argument, NULL, 'c'},     {"log", required_argument, NULL, 'l'},     {NULL, 0, NULL, 0} };   void usage(int status) {     if (status != 0)         printf("Try `%s --help' for more information.\n",              program_name);     else {         printf("IPGen : IP packets generator\n");         printf("Version %s\n", VERSION);         printf("Leo Liang <leo.liang@china.com>\n\n");         printf("Usage: program_name [option] ... src_ip dest_ip\n");         printf("\nIP packets type:\n");         printf("  -t, ...
-+不输入回车读取字符
520 days ago
#include <termios.h> #include <unistd.h> #include <assert.h> #include <string.h> #include <stdio.h> /*------------------------------------------------*/ int getch(void) {       int c=0;       struct termios org_opts, new_opts;       int res=0;           //-----  store old settings -----------       res=tcgetattr(STDIN_FILENO, &org_opts);       assert(res==0);           //---- set new terminal parms --------       memcpy(&new_opts, &org_opts, sizeof(new_opts));       new_opts.c_lflag &= ~(ICANON ECHO ECHOE ECHOK ECHONL ECHOPRT ECHOKE ICRNL);       tcsetattr(STDIN_FILENO, TCSANOW, &new_opts);       c=getchar();           //------  restore old settings ---------       res=tcsetattr(STDIN_FILENO, TCSANOW, &org_opts);       assert(res==0);       return(c); } int main(void){   char c;   c=getch();   fprintf(stderr,"%c",c);   return 0; }     使用tcgetattr函数与tcsetattr函数控制终端 ...
-+c语言 不定参数的实现
521 days ago
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> void CLI_TMP(unsigned int type,...); int main(int argc, char *argv[]) { char d[10]="ABC"; CLI_TMP(0,10,20,30,d,"ddsfssf",'c'); system("PAUSE"); return 0; } void CLI_TMP(unsigned int type,...) { va_list argptr; char temp_buf[256]; int a,b,c; char *d,*e; char f; va_start(argptr, type); a = va_arg (argptr,int); b = va_arg (argptr,int); c = va_arg (argptr,int); d = va_arg (argptr,char*); e = va_arg (argptr,char*); f = va_arg (argptr,int); strcat(d,"aaa"); va_end(argptr); printf("%d,%d,%d,%s,%s,%c\n",a,b,c,d,e,f); }
-+游泳馆
537 days ago
每个星期6下午都去我家附近的游泳馆游泳。来到巴黎以后以后没有什么体育活动,一开始也没有什么爱好,后来发现巴黎的 游泳馆很多,而且便宜,人又少,去了一次以后就喜欢上了。 特地‘偷拍’了几张照片,如果你感兴趣,下次和我一起去呀。 票价是26以下1。5欧元,26以上2。6欧元,每天都有,开一整天。 星期6的时候人都很少,估计平时人更少了。 对了,是室内的,
© 2009 MicrosoftMicrosoft