Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

socket closing question



On Fri, 2 May 2003 10:16:28 -0400
FRamsay at castelhq.com wrote:

> I should probably clarify, the local application did not close the
> socket, but neither did the remote application.
> And yet the socket did close.  So I'm trying to figure out where the
> socket originally closed and from there
> why the socket closed.
If you are using select(2), or if you just read(2) from the socket, you
will get an indication that the socket was properly closed. I believe
that read(2) returns 0 when the remote host properly closes a TCP
socket. If the socket is broken via communications error, read returns
-1 with the appropriate errno set. Select(2) will return with the
appropriate bit set for subsequent read. You might notice messages from
ftp and other utilities that have messages like "closed by remote host".

The write(2) function returns -1 with errno==EPIPE when the socket has
been closed. 
In the above cases it does not matter if the remove end of the socket is
on the local machine or on some remote host. 

However, I have seen cases where something in the data stream has caused
a false indication, but with select(2), read(2) or write(2) you should
be ok. 
-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20030502/d91dcdc5/attachment.sig>



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org