home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / programm / 5829 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  1.4 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!gatech!rpi!ghost.dsi.unimi.it!univ-lyon1.fr!not-for-mail
  2. From: Christophe.Wolfhugel@grasp.insa-lyon.fr (Christophe Wolfhugel)
  3. Newsgroups: comp.unix.programmer
  4. Subject: asynchronously connecting a socket
  5. Date: 5 Jan 1993 16:53:43 +0100
  6. Organization: INSA Informatique (Grasp), Lyon, France
  7. Lines: 30
  8. Message-ID: <1icau7INNg7f@grasp1.univ-lyon1.fr>
  9. NNTP-Posting-Host: grasp1.univ-lyon1.fr
  10.  
  11. The connect(3n) system call when used aynchronously will return -1 with
  12. errno set to EINPROGRESS.  A write select(3n) will indicate completion
  13. of the connect.  Is this an option or is it mandatory ?
  14.  
  15. In order to check return codes, I used a small loop:
  16.  
  17.       while (connect(f->f_file, &ip, sizeof ip) < 0) {
  18.          fprintf(stderr, "errno = %d\n", errno);
  19.          sleep(1);
  20.          continue;
  21.       } /* endif */
  22.  
  23. This returns:
  24.  
  25. errno = 150 (EINPROGRESS)
  26. errno = 11 (EAGAIN)
  27. [many other errno = 11]
  28. Broken pipe
  29.  
  30. and the application dies.  Is this behavior illegal (I know it does not
  31. make much sense to have such a loop).  Shouldn't I get a EALREADY
  32. instead of the EAGAIN ?
  33.  
  34. Also, in a select loop.  Once select indicates a write even for that
  35. file description.  How do I check the connection ?  Redo a connect()
  36. and except errno to be either EISCONN to indicate success, any other
  37. result to indicate failure ?
  38.  
  39. -- 
  40. Christophe Wolfhugel    |    Email: Christophe.Wolfhugel@grasp.insa-lyon.fr
  41.