home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.hp:10101 comp.unix.programmer:4546
- Newsgroups: comp.sys.hp,comp.unix.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!spool.mu.edu!yale.edu!ira.uka.de!rz.uni-karlsruhe.de!rz.uni-karlsruhe.de!chris
- From: chris@rz.uni-karlsruhe.de (Christian Finger)
- Subject: Re: Sockets, timeouts, and HPUX
- Message-ID: <1992Sep5.182349.12673@rz.uni-karlsruhe.de>
- Sender: usenet@rz.uni-karlsruhe.de (USENET News System)
- Reply-To: finger@rz.uni-karlsruhe.de
- Organization: Computer Center, University of Karlsruhe, Germany
- References: <Bu2HJ5.KHA@spock.dis.cccd.edu>
- Date: Sat, 5 Sep 1992 18:23:49 GMT
- Lines: 43
-
- In article <Bu2HJ5.KHA@spock.dis.cccd.edu>, markb@spock.dis.cccd.edu (Mark Bixby) writes:
- | I'm running HPUX 8.02 on a 9000/817. I'm writing a sockets client that talks to
- | a remote server machine. If the server machine is down, the client's
- | connect(2) call takes 75 seconds to time out. Is there any way to change this
- | timeout duration, especially to reduce it to something more reasonable like
- | 15 seconds?
- |
- [ comments about HP's manuals and implementation deleted ]
-
- There's a very easy way: connect() can be interrupted by an alarm signal.
- Here an example:
-
- /* define dummy function somewhere in your source */
-
- dummy() {}
-
- /* the code that connects to the other host */
-
- signal(SIGALRM,dummy);
- alarm(timeout);
-
- if (connect (sock, (char *) &sin, sizeof (sin)) < 0) {
- if (errno == EINTR) {
- /* timeout reached */
- }
- else {
- /* any other error */
- }
- }
-
- /* deactivate time bomb */
-
- alarm(0);
- signal(SIGALRM,SIG_DFL);
-
- Hope that helps,
- Christian
- --
- . Christian Finger | Tel : (+49) 721/608-4038
- ||| Computer Center | Fax : (+49) 721/32550
- \||| University of Karlsruhe | EMail : finger@rz.uni-karlsruhe.de
- / Postfach 6980 | X.400 : S = finger; OU = rz
- D-7500 Karlsruhe 1 | P = uni-karlsruhe; A = dpb; C = de
-