⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inetdserv.c

📁 实战Linux socket编程例题源代码
💻 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 + -