Archived

This topic is now archived and is closed to further replies.

EasyGino

Socket Programming Part Deux

Recommended Posts

Okay so I''m using winsocks to handle my cheesy games network code. But before implementing the client-server aspect into my game I was just testing the code on it''s own. Now I get the client to connect to the server and the server can send a message to the client but for some reason my client cannot send to my server? SOCKET s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); sprintf(sendBuffer, "x = 1 y = 1"); send (s, sendBuffer, sizeof(sendBuffer), 0); thats all my client is trying to do once it connects

Share this post


Link to post
Share on other sites
How is your server checking for incoming messages? A common method to do this is socket polling using select(). You have to sit in a while loop and constantly check to see if there is any data sitting on a connected socket.

It''s even easier if you are using blocking sockets and only one client. Then just make sure the server posts some sort of recv call on that socket, but for a game I''m sure you''d rather nonblocking.

Follow these steps to make a nonblocking server using the select method.

Share this post


Link to post
Share on other sites
quote:
Original post by save yourself
How is your server checking for incoming messages? A common method to do this is socket polling using select(). You have to sit in a while loop and constantly check to see if there is any data sitting on a connected socket.

It''s even easier if you are using blocking sockets and only one client. Then just make sure the server posts some sort of recv call on that socket, but for a game I''m sure you''d rather nonblocking.

Follow these steps to make a nonblocking server using the select method.
Don''t scare him, yet

Can we see your clientcode?

--
You''re Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net''s DirectX FAQ. (not as cool as the Graphics and Theory FAQ)

Share this post


Link to post
Share on other sites