Richard.Draves@RPD.MACH.CS.CMU.EDU (11/30/88)
I ran into two problems compiling xscope for Mach. 4.3 may well have these problems too. Mach doesn't have SO_DONTLINGER. The file scope.c uses perror() before including <errno.h>. The Mach <errno.h> has a prototype declaration for perror() (when __STDC__) and the implicit int declaration conflicts with the later void declaration. I briefly tested xscope on RTs, Vaxen, and Suns without seeing any problems. It looks very useful. Rich *** common.c.~1~ Tue Nov 29 16:07:28 1988 --- common.c Tue Nov 29 16:40:06 1988 *************** *** 148,153 **** --- 148,156 ---- { FD ConnectionSocket; struct sockaddr_in sin; + #ifndef SO_DONTLINGER + struct linger linger; + #endif SO_DONTLINGER enterprocedure("SetUpConnectionSocket"); *************** *** 160,166 **** --- 163,175 ---- } (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0); (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0); + #ifdef SO_DONTLINGER (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0); + #else SO_DONTLINGER + linger.l_onoff = 0; + linger.l_linger = 0; + (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger); + #endif SO_DONTLINGER /* define the name and port to be used with the connection socket */ bzero((char *)&sin, sizeof(sin)); *** scope.c.~1~ Tue Nov 29 16:07:23 1988 --- scope.c Tue Nov 29 17:00:49 1988 *************** *** 9,14 **** --- 9,22 ---- #include "scope.h" + #include <sys/types.h> /* needed by sys/socket.h and netinet/in.h */ + #include <sys/uio.h> /* for struct iovec, used by socket.h */ + #include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ + #include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ + #include <netinet/in.h> /* struct sockaddr_in */ + #include <netdb.h> /* struct servent * and struct hostent * */ + #include <errno.h> /* for EINTR, EADDRINUSE, ... */ + extern int errno; /* ********************************************** */ /* */ *************** *** 458,472 **** /* */ /* ************************************************************ */ - #include <sys/types.h> /* needed by sys/socket.h and netinet/in.h */ - #include <sys/uio.h> /* for struct iovec, used by socket.h */ - #include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ - #include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ - #include <netinet/in.h> /* struct sockaddr_in */ - #include <netdb.h> /* struct servent * and struct hostent * */ - #include <errno.h> /* for EINTR, EADDRINUSE, ... */ - extern int errno; - static int ON = 1 /* used in ioctl */ ; NewConnection(fd) --- 466,471 ---- *************** *** 527,532 **** --- 526,534 ---- FD ServerFD; struct sockaddr_in sin; struct hostent *hp; + #ifndef SO_DONTLINGER + struct linger linger; + #endif SO_DONTLINGER enterprocedure("ConnectToServer"); *************** *** 541,547 **** --- 543,555 ---- } (void) setsockopt(ServerFD, SOL_SOCKET, SO_REUSEADDR, (char *) NULL, 0); (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0); + #ifdef SO_DONTLINGER (void) setsockopt(ServerFD, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); + #else SO_DONTLINGER + linger.l_onoff = 0; + linger.l_linger = 0; + (void) setsockopt(ServerFD, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger); + #endif SO_DONTLINGER /* determine the host machine for this process */ if (ServerHostName[0] == '\0')