Weird Socket behaviour after using NetworkStream
-
I have a client / server system which uses sockets to send a receive messages. The messages are then processed on the server and a response sent back. This all works as expected most of the time but in the case of one particular message, it requires an arbitrary amount of data to follow it so I attach a NetworkStream to the Socket (specifying false to 'ownsSocket' so as not to close the socket early). Now this also works fine but some time after using the NetworkStream I get a message received twice in a single Receive call. The client has not sent it twice but it was received twice. This may happen for the message after I use the NetworkStream or after 100 successful messages after, there seems to be no pattern to it. Now this also seems to happen less and less the more debug messages I add to the application making it very hard to find the problem. The NetworkStream is closed and disposes after use. Does anyone have any idea what could be causing this? Could it just be coincidence that it seems to only happen after I use a NetworkStream?
-
I have a client / server system which uses sockets to send a receive messages. The messages are then processed on the server and a response sent back. This all works as expected most of the time but in the case of one particular message, it requires an arbitrary amount of data to follow it so I attach a NetworkStream to the Socket (specifying false to 'ownsSocket' so as not to close the socket early). Now this also works fine but some time after using the NetworkStream I get a message received twice in a single Receive call. The client has not sent it twice but it was received twice. This may happen for the message after I use the NetworkStream or after 100 successful messages after, there seems to be no pattern to it. Now this also seems to happen less and less the more debug messages I add to the application making it very hard to find the problem. The NetworkStream is closed and disposes after use. Does anyone have any idea what could be causing this? Could it just be coincidence that it seems to only happen after I use a NetworkStream?
-
__DanC__ wrote:
The NetworkStream is closed and disposes after use.
Try without closing the NetworkStream.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)