home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3962 < prev    next >
Encoding:
Internet Message Format  |  1992-07-28  |  1.3 KB

  1. Path: sparky!uunet!cs.utexas.edu!rutgers!ub!galileo.cc.rochester.edu!ee.rochester.edu!moscom!jmp
  2. From: jmp@moscom.UUCP (Joe Palumbos)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: SIGIO & sockets.  is this right?
  5. Message-ID: <3834@moscom.UUCP>
  6. Date: 28 Jul 92 16:11:09 GMT
  7. References: <1992Jul22.004846.220119@zeus.calpoly.edu>
  8. Organization: Moscom Corp., Pittsford, NY
  9. Lines: 34
  10. X-Newsreader: Tin 1.1 PL3
  11.  
  12. kwang@zeus.calpoly.edu (Kevin Wang aka The Scarecrow) writes:
  13. : I am trying to use fcntl() to turn on O_ASYNC so that my program
  14. : will receive a SIGIO when any data comes in across any of its sockets.
  15. : However, it doesn't seem to be working.
  16. : system is AIX (yes, yes, I know) V 1.2.1
  17. : Here's how I turn it on:
  18. :  void SIGIO_ON(int sock)
  19. : {
  20. :     int hold;
  21. :     hold = fcntl(sock, F_GETFL, 0);
  22. :     hold = fcntl(sock, F_SETFL, hold | O_ASYNC);
  23. :     if (-1 == hold)
  24. :         {
  25. :         perror("SIGIO_ON");
  26. :         }
  27. :     return;
  28. : }
  29. : and here's the code that's supposed to be interrupted by the SIGIO:
  30. : [.....]
  31.  
  32.  
  33. After your fcntl() call to make the socket Async, you need
  34. another call: 
  35.  
  36.         fcntl (sock, F_SETOWN, getpid());
  37.  
  38. This will allow your pid (or group; see fcntl(2)) to receive SIGIO.  
  39. -- 
  40. Joe Palumbos    jmp@moscom.com        {rit,tropix,ur-valhalla}!moscom!jmp
  41.