开发者

Why does the exception thrown from Socket.Receive report an exception in my program when the server closed the connection?

I have a connection that I am closing in a server (another executable) using Socket.Close(). In my client on the Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state) call it throws a SocketException stating

An established connection was aborted by the software in your host machine

This gives me the impression that I am closing a co开发者_运维问答nnection that some thread has blocked on a Socket.Receive() or Socket.EndReceive(). Have I done something incorrectly here?


Have you tested with Shutdown() before Close() recommendation for gracefuly closing the socket on the server side as documented ? I would think that a graceful close should not cause the client to report the connection as aborted, this should only happen if the connection is reset (TCP RST).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜