?? inetdserv.c
字號:
/* inetdserv.c: * * Example inetd daytime server : */#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <time.h>#include <sys/types.h>/* * This function reports the error and * exits back to the shell : */static voidbail(const char *on_what) { if ( errno != 0 ) { fputs(strerror(errno),stderr); fputs(": ",stderr); } fputs(on_what,stderr); fputc('\n',stderr); exit(1);}intmain(int argc,char **argv) { int z; int n; time_t td; /* Current date&time */ char dtbuf[128]; /* Date/Time info */ /* * Generate a time stamp : */ time(&td); n = (int) strftime(dtbuf,sizeof dtbuf, "%A %b %d %H:%M:%S %Y\n", localtime(&td)); /* * Write result back to the client : */ z = write(1,dtbuf,n); if ( z == -1 ) bail("write(2)"); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -