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>
36 #ifdef NEEDS_ALLOCFDSET
37 /* Include these if testing against 32 bit fd_set IOMGR. */
39 IOMGR_AllocFDSet(void)
41 fd_set *tmp = (fd_set *) malloc(sizeof(fd_set));
42 memset(tmp, 0, sizeof(fd_set));
47 IOMGR_FreeFDSet(fd_set * fds)
53 /* The TCP spec calls for writing at least one byte of OOB data which is
54 * read by the receiver using recv with the MSG_OOB flag set.
61 Log("Sending OOB.\n");
62 if (send(fd, &c, 1, MSG_OOB) < 0) {
72 Log("Received OOB\n");
73 if (recv(fd, &c, 1, MSG_OOB) < 0) {
80 assertNullFDSet(int fd, fd_set * fds)
83 int n = sizeof(*fds) / sizeof(int);
89 for (i = 0; i < n; i++)
95 * Open file descriptors until file descriptor n or higher is returned.
107 for (i = 0; i < n; i++) {
108 if (fstat(i, &sbuf) == 0)
110 if ((fd = open("/dev/null", 0, 0)) < 0) {
126 /* If flag is set, abort. */
128 Die(int flag, char *msg)
131 extern char *program;
133 (void)sprintf(tmp, "%s: %s: ", program ? program : "", msg);
153 extern char *program;
155 code = gettimeofday(&now, NULL);
159 ltime = localtime(&tt);
161 LWP_CurrentProcess(&pid);
162 fprintf(stderr, "%s 0x%x %02d:%02d:%02d.%d: ", program ? program : "",
163 pid, ltime->tm_hour, ltime->tm_min, ltime->tm_sec, now.tv_usec);
167 vfprintf(stderr, fmt, args);