problem when closing sockets

Hello,

under Linux and Windows, I got a strange and different behaviors when closing socket.

Under Linux if i send in turn 1000 byte arrays over the socket and close the socket after that. the receiver will receive the 1000 packets and then -1. In addition the sender has finnished to send every packets and close the socket before the receiver received everything.

under Windows, the receiver gets few packets and get -1 exactly when the connection is close by the remote peer. So it never receive all packets that have been sent.

I also flush the socket after each call of the write method, but it did not help.

Could you explain me a bit more if this is an issue of the underlying socket implementation on the different OS or if i need to add something(change something) in my code?

thanks

sebastien

[851 byte] By [sebvena] at [2007-11-26 12:42:44]
# 1
You have a bug in your code. TCP doesn't lose packets before delivering an EOF on any platform I am aware of. If it did it wouldn't be TCP.
ejpa at 2007-7-7 16:17:44 > top of Java-index,Archived Forums,Socket Programming...