Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what if i do not know the size of receive buffer in "recv" function . When i m in a while loop the size of receive buffer differs but in "recv" function i have to mention the size before hand, which gives wrong buffer.
Posted
Comments
André Kraak 21-Sep-11 8:14am    
Please share any relevant code with us, seeing the code might us help understand the problem your are facing.

If you wish to change your question use the Improve Question button.

From MSDN[^] (assuming you are using connection oriented Windows Sockets):

For connection-oriented sockets (type SOCK_STREAM for example), calling recv will return as much data as is currently available—up to the size of the buffer specified.
 
Share this answer
 
The status returned from recv() will tell you if more data is available, so you just keep reading until you have all the data that is waiting. See here[^] for full information on this function.
 
Share this answer
 
Take Network Library to work with sockets. It is easy to find.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900