Stopping a TcpListener after calling BeginAcceptTcpClient

前端 未结 5 628
花落未央
花落未央 2021-01-31 18:38

I have this code...

internal static void Start()
{
    TcpListener listenerSocket = new TcpListener(IPAddress.Any, 32599);
    listenerSocket.Start();
    listen         


        
5条回答
  •  萌比男神i
    2021-01-31 19:43

    No you're not missing anything. You can check the IsBound property of the Socket object. At least for TCP connections, while the socket is listening this will be set to true and after you call close it's value will be false. Though, your own implementation can work just as well.

提交回复
热议问题