home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14723 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.3 KB  |  38 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!caen!malgudi.oar.net!news.ans.net!cmcl2!panix!rayc
  3. From: rayc@panix.com (Ray Compton)
  4. Subject: Re: socket timeouts
  5. Message-ID: <1992Dec16.005123.4041@panix.com>
  6. Date: Wed, 16 Dec 1992 00:51:23 GMT
  7. References: <1gbaqcINN3se@bigboote.WPI.EDU>
  8. Organization: League of American Wheelmen - the LAW
  9. Lines: 27
  10.  
  11. In <1gbaqcINN3se@bigboote.WPI.EDU> yeasah@bigwpi.WPI.EDU (Yeasah G. Pell) writes:
  12.  
  13. >Hey wizzards!
  14. >    Q: How can one change the amount of time a connect() function
  15. >       takes to time out when attempting to connect to an unconnected
  16. >       address on the internet?  Currently it waits forever.  I
  17. >       see the select() function has a value for timeout, but I
  18. >       don't know if this is related to connect or not.
  19.  
  20. Yeasah,
  21.  
  22. I've usually done this with an alarm in the following way:
  23.  
  24.     alarm(MAX_TIMEOUT_IN_SECS);
  25.     ret = connect(...);
  26.     if ((ret < 0) && (errno == EINTR)) {
  27.         /* Timed out waiting for connect */
  28.     }
  29.  
  30. It's a bit of a kludge but it will do the trick.
  31.  
  32. /rayc
  33. -- 
  34. *---------------------------------------------------------------------*
  35. * magic    o-->    more magic  | Ray Compton       | "A waste, is a   *
  36. *                              | <rayc@panix.com>  |  terrible thing  *
  37. *   Don't touch that dial !!   | <rayc@command.com>|  to mind" - NRC  *
  38.