Am I doing this right?
I have async sockets and I want to know if I''m doing this correctly. My problem is in the Client program.
I have a start up function that loads WinSock, creates the socket and all that. Then I call connect() at the end of that function.
Then I have the FD_CONNECT message handler, where I do some more stuff. (I assume that FD_CONNECT is called after the connection to the server has been established).
The problem is that even when the server app isn''t running on my other computer, the client app still says it has connected and tries to send data, Even tho it can''t (it does realize this and errors out). Even when the server is running I try to send some data in a char buffer from the client and all I get is garbage received on the server.
Is FD_CONNECT posted after the server sends an accept message? I tried commenting out the accept() function on the server and the client still said it was connected, and this time it could send data with no error! How is that possible? Is it because all the accept() function does is allow the server to send and receive? I thought it also notified the client, which spawned the FD_CONNECT message. Is this true?
==============================
"Need more eeenput..."
- #5, "Short Circuit"
==============================
Drew Sikora
Executive Producer
GameDev.net
are you using tcp or udp?
if its udp, there are no accept()''s or connect()''s (afaik)
if its tcp, that sounds fubar...
if its udp, there are no accept()''s or connect()''s (afaik)
if its tcp, that sounds fubar...
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Have you checked out for error codes in the lparam value in your WndProc() function.
This is how I do it:
case FD_CONNECT:
switch (WSAGETSELECTERROR(lParam))
{
case WSAEAFNOSUPPORT: case WSAECONNREFUSED:
case WSAENETUNREACH: case WSAEFAULT:
case WSAEINVAL: case WSAEISCONN:
case WSAEMFILE: case WSAENOBUFS:
case WSAENOTCONN: case WSAETIMEDOUT:
//Something went wrong while connecting
bConnected = false;
break;
default:
bConnected = true;
//You can begin transferring data now
break;
(sorry for the lack of tabs they don't seem to show up once the message is posted. Anybody knows how to do it?)
Edited by - Lobo on November 12, 2000 11:00:07 PM
This is how I do it:
case FD_CONNECT:
switch (WSAGETSELECTERROR(lParam))
{
case WSAEAFNOSUPPORT: case WSAECONNREFUSED:
case WSAENETUNREACH: case WSAEFAULT:
case WSAEINVAL: case WSAEISCONN:
case WSAEMFILE: case WSAENOBUFS:
case WSAENOTCONN: case WSAETIMEDOUT:
//Something went wrong while connecting
bConnected = false;
break;
default:
bConnected = true;
//You can begin transferring data now
break;
(sorry for the lack of tabs they don't seem to show up once the message is posted. Anybody knows how to do it?)
Edited by - Lobo on November 12, 2000 11:00:07 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement