Problem with my client and connect()

This is a discussion on Problem with my client and connect() within the Networking/Device Communication forums, part of the General Programming Boards category; The problem is this: with no server listening on the port the client will process connect and respond with a ...

Problem with my client and connect()

The problem is this: with no server listening on the port the client will process connect and respond with a success. Futhermore, I can go on to send() data and it will come back saying that it sent the requested number of bytes.

When a server is listening it works fine.
Note: POSTBUFF; is just a #define that prints szBuffer to an edit box.

I believe your problem is that connect will almost always need to block, but since it's non-blocking it returns with an error and WSAEWOULDBLOCK. Since you say a WSAEWOULDBLOCK is not a problem, it tells you that you got success, when you haven't. You should either handle the FD_CONNECT message and check its error code for success/failure, or wait until after you've connected before switching it to non-blocking.

**EDIT**
Just a note, I think async sockets will always give you WSAEWOULDBLOCK if the host isn't there, unless you wait long enough for it to time out the connect attempt and it sets the error to reflect it, and THEN you check WSAGetLastError().

Yea I realized what was going on yesterday, purely by accident. While I'm building the programs I"m having the messages displayed along with the wparam and lparam values, and just happened to notice that fd_connect had a different hiword lparam, and I looked it up and realized what was going on.