How do I do an AcceptAsync of a socket with a timeout?

前端 未结 1 1155
面向向阳花
面向向阳花 2021-01-25 00:37

Here is what I have now:

Socket myNewSocket = currentSocket.Accept();

Here is what I want:

Socket myNewSocket = AcceptWithTimeo         


        
1条回答
  •  抹茶落季
    2021-01-25 01:34

    You could do a BeginAccept and then have a timer that closes the socket to cancel the accept operation. Usually, though, servers just keep an asynchronous accept operation going constantly.

    0 讨论(0)
提交回复
热议问题