home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4262 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  1.2 KB

  1. Xref: sparky comp.unix.programmer:4262 comp.unix.questions:10018
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!swrinde!mips!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!void!ejohnson
  3. From: ejohnson@void.ncsa.uiuc.edu (Eric E. Johnson)
  4. Newsgroups: comp.unix.programmer,comp.unix.questions
  5. Subject: Sockets: Non Blocking I/O, How do I know when its done?
  6. Message-ID: <ejohnson.713655821@void>
  7. Date: 12 Aug 92 21:43:41 GMT
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Organization: University of Illinois at Urbana
  10. Lines: 23
  11.  
  12. I've been working with sockets for a few months, and I've been
  13. trying to do some non blocking sockets.  But, I don't know what to
  14. "watch for" when the socket completes.
  15.  
  16. I turn the socket into a non blocking socket by the following command.
  17.  
  18.     fcntl(s,F_SETFL,FNDELAY);
  19.  
  20. When I use a 
  21.  
  22.     result = read(s,buffer,nbytes);
  23.  
  24. The errno is indeed set to EWOULDBLOCK, but *how* do I check to see
  25. when the data is in, or when the call is completed?  I tried a while
  26. loop wrapped around the read, and watched errno to see if it became 0,
  27. or result returned >0, neither of which happened.
  28.  
  29. Is there function call to make that returns the status of socket in
  30. non blocking mode?
  31.  
  32. Thanks
  33.  
  34. Eric
  35.