🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Am I doing this right?

Started by
2 comments, last by Gaiiden 23 years, 7 months ago
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

Advertisement
are you using tcp or udp?

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
you need to use th ymh socket file included in your library. that should then get you going, read some tutorials on at i think its www.programmingforfun.co.uk that should get you on the way
i am the best

This topic is closed to new replies.

Advertisement