Socket connection reset before I could read the data

I have a problem getting data from a client using .net sockets. The client communicates with TCP and sends one or two packets before closing the connection immediately. The reception is as follows:

Socket newConnection = listener.EndAccept(ar);
newConnection.BeginReceive(myBuffer,0, length, SocketFlags.None, Callback,null);

and execution will not continue. An initial start will immediately raise a SocketException, indicating that the connection was reset. I can not get the received data.

Here is what I see for this connection on wirehark:

SYN // SYN, AKC // AKC
PSH, ACK for 156 bytes
PSH, ACK for 176 bytes
RST, ACK

What is it. Is there any way to get this data, even if the connection is closed by the client?

+5
source share
1 answer

, UDP TCP - .
, TCP - :

Socket newConnection = listener.AcceptSocket();
newConnection.Receive(myBuffer, 0, length, SocketFlags.None);
-1

All Articles