Re: How can I detect a carriage return using java.net
- From: Martin Gregorie <martin@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 28 Oct 2006 19:27:25 +0100
EJP wrote:
Martin Gregorie wrote:>Or, as I said earlier, it could be a deliberate implementation decision in the upper layers of the stack.
It is possible. It is extremely unlikely. It wouldn't comply with any known standard for Unix or sockets. I don't know anything about Fedora but it is certainly true that the Berkeley stacks deliver ECONNRESET, contrary to previous assertions.
An OS with this bug wouldn't be able to make any practical use of TCP/IP or the Internet.
The stack used by DEC Unix on the alphaserver did the same - and that was a Mach based implementation.
Actually, its a pretty benign fault, if it is one. It certainly doesn't make socket connections unusable. Any time a recv() or read() returns a positive value you know you've got data. If you get <=0 the connection has been dropped and you need to clean up and recover. If you got an error you can report it, but this doesn't affect the logic unless it was EAGAIN or EINTR, which both indicate that the recv() returned without reading any valid data but the connection is still intact.
My copy of "UNIX Systems Programming for SVR4" implies that this behavior is the norm from its examples, which all use logic of the form:
while((n = recv()) >0)
process the message
if (n < 0)
decode errno and output the error message
stop.
and the Linux manpage says more or less the same. Neither explicitly mentions any error indicating that the connection has failed.
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
.
- Follow-Ups:
- References:
- How can I detect a carriage return using java.net
- From: Angus
- Re: How can I detect a carriage return using java.net
- From: Gordon Beaton
- Re: How can I detect a carriage return using java.net
- From: Angus
- Re: How can I detect a carriage return using java.net
- From: Gordon Beaton
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- Re: How can I detect a carriage return using java.net
- From: Martin Gregorie
- Re: How can I detect a carriage return using java.net
- From: EJP
- How can I detect a carriage return using java.net
- Prev by Date: Re: can anyone tell me how to broadcast message in Network.
- Next by Date: Re: Java equivalent of C++ Spirit or Boost Graph Library ?
- Previous by thread: Re: How can I detect a carriage return using java.net
- Next by thread: Re: How can I detect a carriage return using java.net
- Index(es):
Relevant Pages
|