Click to See Complete Forum and Search --> : recv() call does not block


dave_rich
July 4th, 2008, 03:19 PM
I have one client talking to two servers. The client exe links to a static library which establishes the sockets with the two servers and communicates with them. Now first time when I estbalish the connection with the two servers, I am able to send and receive data normally. But when I get out of the static library and again call the library to communicate further with the two servers, things mess up. I can send data to the servers, using the sockets which are declared as global in the library, however, the recv call does not block for data, it just does not wait and goes ahead and I get an empy buffer......

Any clues, help, suggestions would be welcome.

Thanks in advance
Dave

dave_rich
July 4th, 2008, 03:39 PM
On further probing, I see that the socket on the client side, receives around 512 or something bytes of junk data and then the call actually blocks and the data sent from the server is received properly, so is there something I can use to say flush all data if there is any (cos in my case, I am sure there wont be any useful data before I send something to the server).......so my receive stream stays clean and receives the data directly from the server and is able to ignore this junk that it is getting now before getting the useful data

Thanks,
Dave

DreamShore
July 5th, 2008, 02:10 AM
1. There is no such idea as "get out of the static library". What do you mean by that.
2. Check the return value of recv(), and WSAGetLastError() to see what has happened.
3. The server side is not written by yourself? Well it is one way that is to expect data, unexpected data should be ignored if you don't want to report error.