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?
--
Does anyone know?
--
The only Information I have been able to find is for Linux, and it hasQuote:>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?
--
***************************************************************************
Relying on the government to protect your privacy is like asking a peeping tom
to install your window blinds. - John Perry Barlow
From "UNIX Network Programming", p. 330: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?
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".
>>Does anyone know?
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()?
--
If connectivity is lost you shouldn't find out about it unless (1) you'reQuote:> 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 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
: 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?
: --
What does your program do it your read()/recv() returns -1?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.
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,
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.
8. An anatomy of a "Respawning too fast." error
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?