Doing asynchronous I/O on sockets in linux

Doing asynchronous I/O on sockets in linux

Post by Bob Cross » Thu, 22 Jul 1993 03:10:14



I have an application (Network Time Protocol) that wants to
receive a signal (SIGIO or its equivalent) every time a packet
arrives on a socket.  I've tried

ioctl( fd, FIONBIO, ( char *) &on)

to make the system calls non-blocking, and

ioctl( fd, FIOASYNC, ( char *) &on)

where

int on = 1;

to do the asynchronous part, but SIGIO doesn't seem to be generated.

NTP sends UDP packets, sets a timer (SIGALRM), and
waits for either SIGIO or SIGALRM.

I know SIGALRM works because I wrote a small program to test it
and NTP generates five out-going packets before quitting.
But it looks like the socket isn't generating SIGIO.  I see the
return packets on the network with a net analyzer, but the program
never gets to the SIGIO handling routine (I put a print statement
in there).

I've looked through the linux fcntl and ioctl code, and through
the net/socket.c and the net/inet/sock.c code, but can't figure
this out.  Any help would be greatly appreciated.  Can anyone
explain this to me?

I'm using linux-0.99.10 and net-2 (net-010).  Generally, net-2 works
on this system.  I have minor problems with rlogin, rsh, ftpd, etc.,
but telnet, ftp, nntp, smtp, seem to work well.

Thanks in advance.

Bob Crosson

 
 
 

Doing asynchronous I/O on sockets in linux

Post by Stephen Tweed » Fri, 23 Jul 1993 08:27:28


Hi,


Quote:> I have an application (Network Time Protocol) that wants to
> receive a signal (SIGIO or its equivalent) every time a packet
> arrives on a socket.  I've tried
>    ioctl( fd, FIONBIO, ( char *) &on)
> to make the system calls non-blocking, and
>    ioctl( fd, FIOASYNC, ( char *) &on)
> where
>    int on = 1;
> to do the asynchronous part, but SIGIO doesn't seem to be generated.

Unfortunately, Linux doesn't yet do async IO.  Not on pipes, ttys, or
- you got it - sockets.  Zilch.  You could consider this a "feature". :-(

Cheers,
 Stephen.
---

Department of Computer Science, Edinburgh University, Scotland.