简体   繁体   中英

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

Here is what I have now:

Socket myNewSocket = currentSocket.Accept();

Here is what I want:

Socket myNewSocket = AcceptWithTimeout(currentSocket, timeoutInMilliseconds)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM