Listen() Not Blocking Correctly - Programmer

This is a discussion on Listen() Not Blocking Correctly - Programmer ; So uhh... Whenever I run this network program listen isn't blocking
properly. It's not waiting for incoming connections, it's just
instantly going down to accept(), and accept() is returning an
error... I have no idea why listen() isn't blocking. I ...

Listen() Not Blocking Correctly

So uhh... Whenever I run this network program listen isn't blocking
properly. It's not waiting for incoming connections, it's just
instantly going down to accept(), and accept() is returning an
error... I have no idea why listen() isn't blocking. I ran this
program by itself (with no interacting client program running) and
that is what it does. Output:

Listening on socket...
ERROR.

If I replace printf("ERROR."); with perror("ERROR."); it says:

Listening on socket...
ERROR. No error found

But that doesn't really make sense because it wouldn't be going
through the if statement if there was no error, it will only go
through the if statement if the accept call returns INVALID_SOCKET. Ok
here is the code and a privatepaste for easy viewing (http://privatepaste.com/4503Yg6ut2 ):