From owner-freebsd-questions Sun Mar 30 09:39:05 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id JAA03212 for questions-outgoing; Sun, 30 Mar 1997 09:39:05 -0800 (PST) Received: from relay-11.mail.demon.net (relay-11.mail.demon.net [194.217.242.137]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id JAA03203 for ; Sun, 30 Mar 1997 09:39:00 -0800 (PST) Received: from longacre.demon.co.uk ([158.152.156.24]) by relay-11.mail.demon.net id aa1127204; 30 Mar 97 18:30 BST From: Michael Searle Message-ID: To: questions@freebsd.org Subject: Problem with select() Date: Sun, 30 Mar 1997 18:28:57 BST X-Mailer: Offlite 0.09 / Termite Internet for Acorn RISC OS Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Please could someone point me in the right direction here? As far as I can see I'm doing as the accept() and select() man pages say, and the same as the ftp client does. I'm writing an Internet server, with a blocking socket. In two places though, I need to do a non-blocking read from it as it is reading from other clients at the same time. In the first, it is checking for a new client, so I am selecting on read (to check whether I can call accept() without blocking.) The other is similar, but the sockets are already open - it's just a normal select on read. Without the select, it works OK, but blocks until a client connects - as expected. With it, the select never returns 1 so it never gets to being able to accept the client. These are the relevant bits of code: struct fd_set sel; struct fd_set ready; struct timeval timezero; timezero.tv_sec = 0; timezero.tv_usec = 0; serverFd = socket(AF_INET, SOCK_STREAM, DEFAULT_PROTOCOL); FD_ZERO(&sel); FD_SET(serverFd, &sel); bind (serverFd, serverSockAddrPtr, serverLen); listen (serverFd, 2); while (1) { if (select(1, &sel, (struct fd_set *) 0, (struct fd_set *) 0, &timezero) == 1) { fprintf(stderr,"select OK\n"); newFd = accept (serverFd, clientSockAddrPtr, &clientLen); fprintf(stderr,"accept OK\n"); for(y=0;y } } Thanks, Michael. -- Michael Searle - searle@longacre.demon.co.uk