Winsock tutorial

Aug 25, 2008 at 3:40pm
hello, im already messing around with a winsock tutorial i found on rohitab.com. on the server side i want to catch the incoming strings (which the client sends) and do an "if/then", so IF the client sends a certain string THEN i can call another funtion at server side. but i cant find the variable which holds the incoming string! so i dont know which variable i have to check! can you please help me? thanks so much... sorry its a bit much code...

Its the tutorial at
http://www.rohitab.com/discuss/index.php?showtopic=30982&st=0
Aug 25, 2008 at 4:56pm
I would check out Beej's networking guide - it is much more thorough then the one you are currently using. http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html

I assume you are using recv(), in that case the string will be in the buffer you sent as an argument to recv:
ssize_t recv(int s, void *buf, size_t len, int flags);
Here buf is where your message is stored. Be warned: just because your client sent "Hello world", doesn't mean the receiver will receive the whole message! It could only receive "Hello w" in which case you would need to loop and call recv() again and put the message together. To solve this problem, your sender should attach the size of the message to the start so the receiver knows how many characters follow. All this stuff is covered in the guide though.
Aug 26, 2008 at 11:13am
thanks, ill check it out!
Topic archived. No new replies allowed.