exception conditions on sockets

exception conditions on sockets

Post by Jeffrey W Perciv » Sun, 13 Feb 1994 01:44:46



When using select() to check a socket file descriptor, one of the
three FD bitfields is for exception conditions.  I haven't been
able to find any mention of what these conditions might be.

Does anyone know?
--

 
 
 

exception conditions on sockets

Post by Paul Arboga » Mon, 14 Feb 1994 12:20:16




Quote:>When using select() to check a socket file descriptor, one of the
>three FD bitfields is for exception conditions.  I haven't been
>able to find any mention of what these conditions might be.

>Does anyone know?

The only Information I have been able to find is for Linux, and it has
only one exception condition:  Out of Band Data.  

--
******************************************************************************
Relying on the government to protect your privacy is like asking a peeping tom
to install your window blinds.    - John Perry Barlow

 
 
 

exception conditions on sockets

Post by W. Richard Steve » Mon, 14 Feb 1994 12:38:47


Quote:> When using select() to check a socket file descriptor, one of the
> three FD bitfields is for exception conditions.  I haven't been
> able to find any mention of what these conditions might be.
> Does anyone know?

From "UNIX Network Programming", p. 330:

1. The arrival of out-of-band data for a socket.
2. The presence of control status information to be read from the master
   side of a pseudo-terminal that has been put into packet mode.

Similar information is on p. 400 in "Advanced Programming in the UNIX
Environment".


 
 
 

exception conditions on sockets

Post by Jeffrey W Perciv » Tue, 15 Feb 1994 03:32:40




>>When using select() to check a socket file descriptor, one of the
>>three FD bitfields is for exception conditions.  I haven't been
>>able to find any mention of what these conditions might be.

>>Does anyone know?

Let me follow up on my own posting with more context.  What seems to be
happening is this:  I'm reading and writing sockets merrily, and
detect when clients go away by reading zero bytes after select() told
me the socket was readable.  This handles the situation when the process
on the other end of the socket exits or is aborted.

However, the client can go away more abruptly: in our case, say,
somebody slices the phone line or unplugs the ethernet connector.  In
this situation, I don't get the normal indication of a client going
away.  Rather, my end of the socket does nothing, then 10 minutes
later, my program exits (evidently TCP is doing the exit).  No core
file is left.  It just ends, without me telling it to do so.

How can I close the offending socket gracefully?  How do I prevent
what I think is the TCP layer doing an exit()?
--

 
 
 

exception conditions on sockets

Post by W. Richard Steve » Tue, 15 Feb 1994 21:25:21


Quote:> However, the client can go away more abruptly: in our case, say,
> somebody slices the phone line or unplugs the ethernet connector.  In
> this situation, I don't get the normal indication of a client going
> away.  Rather, my end of the socket does nothing, then 10 minutes
> later, my program exits (evidently TCP is doing the exit).  No core
> file is left.  It just ends, without me telling it to do so.

If connectivity is lost you shouldn't find out about it unless (1) you're
exchanging data with the other end, in which case the 10 minute eventual
timeout is typical for TCP, or (2) you've set the keepalive option (which
takes a default of 2 hours to detect the loss).

If you timeout while sending data, your socket will be marked readable
and the read returns the errno of ETIMEDOUT.  That's what most reasonable
Unix implementations that I've seen do.  You never mention the type of
system you're on.  It sounds broken.

        Rich Stevens

 
 
 

exception conditions on sockets

Post by Paul Smi » Tue, 15 Feb 1994 21:48:45





: >>When using select() to check a socket file descriptor, one of the
: >>three FD bitfields is for exception conditions.  I haven't been
: >>able to find any mention of what these conditions might be.
: >>
: >>Does anyone know?

: Let me follow up on my own posting with more context.  What seems to be
: happening is this:  I'm reading and writing sockets merrily, and
: detect when clients go away by reading zero bytes after select() told
: me the socket was readable.  This handles the situation when the process
: on the other end of the socket exits or is aborted.

: However, the client can go away more abruptly: in our case, say,
: somebody slices the phone line or unplugs the ethernet connector.  In
: this situation, I don't get the normal indication of a client going
: away.  Rather, my end of the socket does nothing, then 10 minutes
: later, my program exits (evidently TCP is doing the exit).  No core
: file is left.  It just ends, without me telling it to do so.

: How can I close the offending socket gracefully?  How do I prevent
: what I think is the TCP layer doing an exit()?

Try setting setsockopt(fd,SOL_SOCKET, SO_KEEPALIVE), this will cause you to
get a select with hangup or error within severla seconds of the line loss.
Your exit issue sounds like a bug.  Does your OS have a trace capability
like SYSV.4 (truss) to trace the system calls after y9our line loss?

Put in some fprintf(stderr's to dump what calls are doing what?

: --

 
 
 

exception conditions on sockets

Post by John Hasca » Wed, 16 Feb 1994 23:20:43



Quote:}Let me follow up on my own posting with more context.  What seems to be
}happening is this:  I'm reading and writing sockets merrily, and
}detect when clients go away by reading zero bytes after select() told
}me the socket was readable.  This handles the situation when the process
}on the other end of the socket exits or is aborted.
}
}However, the client can go away more abruptly: in our case, say,
}somebody slices the phone line or unplugs the ethernet connector.

What does your program do it your read()/recv() returns -1?

John
--
John Hascall                   ``An ill-chosen word is the fool's messenger.''
Systems Software Engineer
Project Vincent
Iowa State University Computation Center  +  Ames, IA  50011  +  515/294-9551

 
 
 

1. Clearing exception condition on a socket

Can someone tell me where it is documented how to clear the exception condition
on a socket after you send some out of band data?

I couldn't find it anywhere, and out of desparation began looking at the
source code to "telnet", where I found the answer buried in some comments.
[The answer is that it is not cleared until you do a normal read from the
socket, doing a recv of the out of band data is not enough]  Surely this must
be documented in a more accessible location.

I am using SunOS 4.1.1b on a SPARCstation IPX.

Thanks,

2. getty_ps and RTSCTS

3. race conditions with two sockets?

4. where are netstat's options -i

5. Out-of-band data on sockets - how to detect "true" exceptions ?

6. Help me get up to speed, please.

7. Socket exceptions

8. An anatomy of a "Respawning too fast." error

9. Socket Exceptions

10. socket exceptions on SysV.4

11. Run-time exception; no handler for exception problem

12. Sockets sockets and more sockets

13. Socket, Socket, whose got the socket?