On Feb 28, 2010, at 5:52 AM, Tobias Russell wrote:
I'm in the midst of writing a MUD for PDP-11s
running under BSD 2.11
and have run into a problem getting non-blocking I/O working.
I initially wrote a simple test program to setup a non-blocking socket
and accept connections then echo back anything typed to all connected
sessions. This worked fine. However now I've placed the exact same
code into my MUD development, the sockets are blocking.
I've got the following in my setup of the socket:
/* Set socket to non-blocking */
if( ioctl(s,FIONBIO) == -1 ) {
printf("Error ocurred");
}
which I believe should make the socket non-block and when I run up the
code it doesn't throw a failure on the ioctl, however the socket
definitely remains in blocking mode.
Anyone have any ideas? I've been scratching my head on this one for
days now
FIONBIO takes an argument, which is a pointer to an integer.
Here's how you want to do this under 2.11BSD:
-------------------------
int on = 1;
...
...
...
if (ioctl(s, FIONBIO, &on) == -1) {
printf("ioctl() failed\n");
}
-------------------------
-Dave
--
Dave McGuire
Port Charlotte, FL