*
* Usage: echod -h give all info
*
- * $Id: TCP_echod.c,v 1.10 2003/07/29 22:41:36 piccardi Exp $
+ * $Id: TCP_echod.c,v 1.11 2003/08/02 19:54:11 piccardi Exp $
*
****************************************************************/
/*
*/
int list_fd, conn_fd;
int waiting = 0;
+ int compat = 0;
pid_t pid;
struct sockaddr_in serv_add, cli_add;
socklen_t len;
*/
int i;
opterr = 0; /* don't want writing to stderr */
- while ( (i = getopt(argc, argv, "hdiw:")) != -1) {
+ while ( (i = getopt(argc, argv, "hdicw:")) != -1) {
switch (i) {
/*
* Handling options
case 'i':
demonize = 0;
break;
+ case 'c':
+ compat = 1;
+ break;
case 'd':
debugging = 1;
break;
* Main code beginning
*
* ***********************************************************/
- /* install SIGCHLD handler */
- SignalRestart(SIGCHLD, HandSigCHLD); /* establish handler */
+ /* Main code begin here */
+ if (compat) { /* install signal handler */
+ Signal(SIGCHLD, HandSigCHLD); /* non restarting handler */
+ } else {
+ SignalRestart(SIGCHLD, HandSigCHLD); /* restarting handler */
+ }
/* create socket */
if ( (list_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("Socket creation error");
printf(" -h print this help\n");
printf(" -d write debug info\n");
printf(" -i use interactively\n");
+ printf(" -c disable BSD semantics\n");
printf(" -w N wait N sec. before calling accept\n");
exit(1);
}
char buffer[MAXLINE];
int nread, nwrite;
char debug[MAXLINE+20];
- int size;
/* main loop, reading 0 char means client close connection */
while ( (nread = read(sockfd, buffer, MAXLINE)) != 0) {
if (nread < 0) {