HELP! BSD select() on socket (WIN/TCP for VMS) -> updated
Holger Zessel
zessel at tsetse.informatik.uni-kl.de
Thu Mar 22 23:11:02 AEST 1990
TAYBENGH%NUSDISCS.BITNET at 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 <hostname> 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 <sys/types>
^.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 at informatik.uni-kl.de
or zessel%informatik.uni-kl.de at relay.cs.net (from usa)
Fachbereich Informatik, SFB124-D1
Universitaet Kaiserslautern, West-Germany
More information about the Comp.unix.wizards
mailing list