If AsyncAccept (or any AsyncXXX operation, for that matter) cannot be satisfied immediately, then it will return true, indicating that the operation will be performed asynchronously. When this happens, the callback event will ultimately be fired on the thread stream. Even if it will return to the user interface thread (because it was initiated there), it will do so through a message.
AsyncAccept will most likely return true, because if there are any really non-waiting socket connections (see backlog in Listen ), you are waiting for a client connection.
Therefore, StartAccept () will simply exit without calling ProcessAccept, and ProcessAccept, when (and if) it fires, is likely to be in a different thread.
source share