Problem getting non-blocking sockets going on BSD 2.11

Dave McGuire mcguire at neurotica.com
Sun Feb 28 09:32:16 CST 2010


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




More information about the cctalk mailing list