So how can I get handle of a console application
Or there is some other way to do asynchronous socket programming in console application.
Thanks.
Visual C++ General
Maybe you should consider an alternative solution based on events. First create an event using WSACreateEvent or CreateEvent function. Then associate this event with network event using WSAEventSelect function. After this you can check or wait for network events using WaitForSingleObject or WaitForMultipleObjects functions.
You can also use CSocket or CAsyncSocket class from MFC library, which creates for you a hidden window as a target for network messages.
I hope this makes sense.
The wait function returns WSA_WAIT_EVENT_0 if one of network events occurred during 1 second interval, i.e. the host is ready for reading or writing, or closed the socket. Otherwise it returns WSA_WAIT_TIMEOUT after 1 second. In order to determine which of events occurred, try WSAEnumNetworkEvents. If you need just to check the readiness without waiting, then specify zero timeout.
Probably you can obtain more precise information in MSDN or at http://www.sockaddr.com/ExampleSourceCode.html or http://www.codeproject.com/internet/networkevents.asp.