Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!unido!uklirb!incas!tsetse!zessel From: zessel@tsetse.informatik.uni-kl.de (Holger Zessel) Newsgroups: comp.unix.wizards Subject: Re: HELP! BSD select() on socket (WIN/TCP for VMS) -> updated Message-ID: <3917@incas.informatik.uni-kl.de> Date: 22 Mar 90 13:11:02 GMT References: <22826@adm.BRL.MIL> Sender: news@incas.informatik.uni-kl.de Lines: 57 TAYBENGH%NUSDISCS.BITNET@cunyvm.cuny.edu writes: .... >/* Filename : select_recv.c In general I would say, the program is correct. At least on our suns (SunOs 4.03) and Vaxen (Ultrix 2.2) it runs as expected: - stopping in select After that I made a telnet local_port to get an easy tcp connection.. - Now the select comes back with one bit set in ready. Accept goes ok and the recv gets some bytes I typed in telnet. Every string I type in on demand is echo on the other side by telnet. Seems everythink is ok. But I have some annotations. There may be bug in your libs or os if selct does not block. >#include ^.h missing .... > FD_ZERO(&ready); > FD_ZERO(&write); > FD_ZERO(&except); > FD_SET(sock, &ready); > FD_SET(sock, &write); > FD_SET(sock, &except); I think you don't need to set it in write as it is not your aim to write on the accept socket. On our machines select blocks as sock is not connected and one is not able to write or read on it. You should try it with throwing out FD_SET(sock, &write) and FD_SET(sock, &except). You don't need them. > /* Null pointer is not working, giving acess violation problems! > if ((nfd = select(sock+1, &ready, 0, 0, &to)) <0) */ The fact that this bombs is suspicious to me. I don't see a bug in the expression. There may be a bug in select... > if ((nfd = select(sock+1, &ready, &write, &except, &to)) <0) > { > perror("select"); > break; > } > /* > * select() always return with nfd set to 1 > */ Mine did not, I don't know what's happening on your machine. Hope that helps. I do not e-mail this and poost it here as there may be people knowing of a bug in select. Holger ---------------------------------------------------------------- Holger Zessel, uucp: ...!uunet!unido!uklirb!incas!zessel or zessel@informatik.uni-kl.de or zessel%informatik.uni-kl.de@relay.cs.net (from usa) Fachbereich Informatik, SFB124-D1 Universitaet Kaiserslautern, West-Germany