Socket.Close doesn't really close tcp socket? (c#)

前端 未结 4 809
时光取名叫无心
时光取名叫无心 2021-02-05 22:16

It seems that using socket.Close() for a tcp socket, doesn\'t fully close the socket. In the following example I\'m trying to connect to example.com at port 9999, which is not o

4条回答
  •  甜味超标
    2021-02-05 23:05

    You're calling *Begin*Connect - so doing it asynchronously. You're quite possibly trying to close the socket before it's even connected - so when it then connects, it remains open.

    Try connecting synchronously - or closing it in OnSocketConnected so you can see the effect of closing a genuinely connected socket.

提交回复
热议问题