2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* selsubs.c - common code for client and server. */
16 #include <sys/select.h>
17 #include <sys/types.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
24 #include <sys/ioctl.h>
28 #include <afsconfig.h>
29 #include <afs/param.h>
38 #ifdef NEEDS_ALLOCFDSET
39 /* Include these if testing against 32 bit fd_set IOMGR. */
41 IOMGR_AllocFDSet(void)
43 fd_set *tmp = (fd_set *) malloc(sizeof(fd_set));
44 memset((char *)tmp, 0, sizeof(fd_set));
49 IOMGR_FreeFDSet(fd_set * fds)
55 /* The TCP spec calls for writing at least one byte of OOB data which is
56 * read by the receiver using recv with the MSG_OOB flag set.
63 Log("Sending OOB.\n");
64 if (send(fd, &c, 1, MSG_OOB) < 0) {
74 Log("Received OOB\n");
75 if (recv(fd, &c, 1, MSG_OOB) < 0) {
82 assertNullFDSet(int fd, fd_set * fds)
85 int n = sizeof(*fds) / sizeof(int);
91 for (i = 0; i < n; i++)
97 * Open file descriptors until file descriptor n or higher is returned.
109 for (i = 0; i < n; i++) {
110 if (fstat(i, &sbuf) == 0)
112 if ((fd = open("/dev/null", 0, 0)) < 0) {
128 /* If flag is set, abort. */
130 Die(int flag, char *msg)
133 extern char *program;
135 (void)sprintf(tmp, "%s: %s: ", program ? program : "", msg);
155 extern char *program;
157 code = gettimeofday(&now, &tz);
160 ltime = localtime((time_t *) & now.tv_sec);
162 LWP_CurrentProcess(&pid);
163 fprintf(stderr, "%s 0x%x %02d:%02d:%02d.%d: ", program ? program : "",
164 pid, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, now.tv_usec);
168 vfprintf(stderr, fmt, args);