Skip to main content
gamedev.net
🔒 Locked

winsock

Started by jobrady 1 reply 300+ views
Original Post
jobrady
jobrady
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
BrownBean
BrownBean
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
stryx
stryx
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
Anything that requires finding convex hulls in realtime isstarting to sound like a bad idea. -- John Carmack

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.