Computing.Net > Forums > Programming > Reading data from socket c++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Reading data from socket c++

Reply to Message Icon

Name: Pavel
Date: August 16, 2003 at 05:36:14 Pacific
OS: WinNT
CPU/Ram: pentium 3
Comment:

This is the code:
int ret;
char buffer[1024];
memset(buffer, 0, sizeof (buffer));
ret = recv(theSocket, buffer, sizeof(buffer), 0);

Sometime i read all data from socket queue and sometime the recv function read only one byte and leave bytes in socket queue.

Why ??? How always read all data from socket queue ?

Thank's




Sponsored Link
Ads by Google

Response Number 1
Name: micah
Date: August 16, 2003 at 23:38:44 Pacific
Reply:

Thats because your computer has not recieved all the data so it cant be in the sockets buffer. What you can do is set the socket to non-blocking then loop the recv() until you have all the data. If you cant figure it out I can get you some code later.

-Micah


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Reading data from socket c++

Reading data from a sound card www.computing.net/answers/programming/reading-data-from-a-sound-card/15506.html

reading data from smart card www.computing.net/answers/programming/reading-data-from-smart-card/7887.html

Unable to read data from the tran www.computing.net/answers/programming/unable-to-read-data-from-the-tran/14350.html