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

前端 未结 1 1156
面向向阳花
面向向阳花 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)
提交回复
热议问题