HELP: select() under sockets


Gil Widdowson (mtune!codas!ablnc!gil@RUTGERS.EDU)
4 Sep 87 12:51:32 GMT


I am trying to modify an application to use select(3w) to manage
incoming data. I am working on 3B2s, 3B20s, and UTS using sockets
under Wollongong's/AT&T's TCP/IP over Ethernet. 3Bs are running
TCP release 1.1. Anyway, it does not seem to work at all. So I set
up a little client/server model where the server uses select() to
determine when the client has sent it data on an established virtual circuit.
When I use block mode, it pends forever, though if I break out using sbd(1),
data is there. If I use timed polling mode, it always returns
zero forever. Is it me or our sockets service??

code fragment
...
set up connection on file descriptor nfd

/*
***********************************************
** Select test code
** if timed_select FALSE
** pend until our fd is ready for readying
** else
** do polling once a second
** until our fd is ready for readying
***********************************************
*/
readfds = (1<<nfd); writefds = 0; eventfds = 0; numfds = 1;

if (timed_select == 0) {
        numfds = select(numfds, &readfds, &writefds, &eventfds, 0);
        if (numfds == -1) {
                perror("select() error");
                exit(1);
                }
        fprintf(stderr, "numfds = %d and readfds = %X\n",numfds, readfds);
        }
else {
        int sav_readfds; int sav_numfds;

        sav_readfds = readfds;
        sav_numfds = numfds;
        nodata = 1;
        while (nodata) {
                readfds = sav_readfds;
                numfds = sav_numfds;
                numfds=select(numfds, &readfds, &writefds, &eventfds, &timeout);
                if (numfds == -1) {
                        perror("select() error");
                        exit(1);
                        }
                else {
                        if (numfds == 0) { continue; }
                        else { nodata = 0; }
                        }
                }
        }
Do recv() of data.
...

Please send any/all humiliating/enlightening responses via email.
thanks,

Gil Widdowson AT&T DP&CT Maitland FL
{allegra,amdahl,clyde,codas,cuae2,garage,houxm,ihnp4,mtune,research}!abfli!gil
(305) 660-6123 (8-754)



This archive was generated by hypermail 2.0b3 on Thu Mar 09 2000 - 14:39:15 GMT