Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!doug@ws5.cis.temple.edu From: doug@ws5.cis.temple.edu (Doug Bagley) Newsgroups: comp.unix.wizards Subject: Help with select Message-ID: <12404@brl-adm.ARPA> Date: 15 Mar 88 15:11:11 GMT Sender: news@brl-adm.ARPA Lines: 90 I am trying to learn how to use sockets in Ultrix 2.0 at a site with no sources. My problem is with the select function. When I provide the readfds and writefds parameters to the select function, only the writefds parameter gets changed whether or not the process on the other end of the socket is doing a read or a write. Strangely enough, if I make the writefds NULL or 0, and if the remote process is only writing to this one, everything works fine -- the remote process' writes show up in the readfds (telling the selecting process that it can read). Could someone help me out by: correcting any misinterpretation on my part, or by referring me to a good reference on BSD IPC in the Internet domain, or perhaps sending me a sample of code that uses select to multiplex reads and writes at the same time? I have included a stripped down version of the offending program below. Thanks in advance, Doug Bagley (CSNET: bagley@temple.edu) #include #include #include #include #include #include main(argc, argv) int argc; char *argv[]; { struct sockaddr_in sin, from; int i, s, s2, smax, smin, fromlen, mask, writefds[1], readfds[1], nfound; /* get the port number from command line arg */ if (argc != 2) exit(1); s = socket(AF_INET, SOCK_STREAM, 0); if (s == -1) exit(1); sin.sin_family = AF_INET; sin.sin_port = htons(atoi(argv[1])); if (bind(s, (caddr_t)&sin, sizeof(sin)) < 0) exit(1); /* listen on specified port */ listen(s, 5); smax = s+1; smin = smax; /* mask contains all currently known socket descriptors */ mask = (1< smax) smax = s2+1; } if (readfds[0] != (1<