I'm currently building a Socket class in C++ which uses winsock 2.
I started with simple initialize, connect and a listen functions which were working perfect.
When I tried to make an asynchronous listen function it didn't work. I created a window and placed a WSAAsyncSelect() in the listen function, but the thing just wouldn't listen (literally).
After that, my normal (blocking) listen function wouldn't work anymore either. I don't know why, because I had changed nothing in that part of the code. Even after removing all the things I added for the asynchronous listener it wouldn't work (I restored the old project with subversion). I even tried the example code from a tutorial which was working before but with no effect.
The problem is that the listen function doesn't wait while it should. The windows firewall does ask me if I want to unblock the program but there is no listening connection popping up in netstat (there was before all of this).
Does anyone know how to fix this? It's really hard to find anything on google since it doesn't give any error or something.
For completeness, this is a part of the code:
if (bind(m_socket, (LPSOCKADDR)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
return;
listen(m_socket, 1)
If I replace those lines with this one it does connect properly:
if (connect(m_socket, (LPSOCKADDR)&sockAddr, sizeof(sockAddr)) == SOCKET_ERROR)
return false;