As pointed out in post#3, the CAsyncSocket class requires a message loop for successful operation. Thus, it cannot be used in a console application.

It also cannot be used in a worker thread, for the same reason, i.e., a worker thread does not have a message loop.

Why do you think you need a separate thread? One of the purposes of CAsyncSocket was to allow asynchronous operation within the context of the main GUI thread.

Mike

PS: You might be seeing some oddball behavior because of the use of a message box for debugging. A message box will run a message loop (the default modal loop inside of Windows) while it is displayed. But as mentioned in post #9 above, because CAsyncSocket is driven by Windows messages, it generally is a bad idea to debug with AfxMessageBox. Use TRACE statements instead.