Archived

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

jobrady

winsock

Recommended Posts

Ive finally decided to try and figure out how to use winsock. Working off stuff I''ve found on the internet I''ve figured out how to make a client/server app. My problem is that if the order of communication is not predetermined it doesn''t seem to work. If the server is blocking the socket waiting to recv() it cannot send(). Do I need to use two ports-one to send data in each direction??? I presume this is a really simple problem and Im being blind Thanks, Joe

Share this post


Link to post
Share on other sites
Look into a function called "select (...)"

This function will tell if you have any data to be read in a
selected port. If so, then use "rec ( ... )" to read the port.
If there isn''t anything then don''t use the blocking
function "rec." This way you can simply send, and read only when
you have data to read.

BrownBean

Share this post


Link to post
Share on other sites
Another way to do this is to use non-blocking sockets or async-sockets.
You''ll find tutors for both here on gamedev.net

@ Async sockets windows tells you WM_READ,... if something is to read. very handy.

@ non blocking are for 16 bit apps and a bit different.

Just look @ the tutors.

Nate Miller has a cool nonblocking example with source to look at !

I hope this helps

Share this post


Link to post
Share on other sites