C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-25-2003, 12:02 PM   #1
Registered User
 
Join Date: Jun 2003
Posts: 31
Post recv() problem

in i simple program that use sockets how can i know if the recv() function has received all data ???
better:
if the client send a message but the send not send all data and then the client must call another time the send() function to be sure that all data will be send; how i can know if recv function is correct(receive all data)??

P.S. my english is very bad, sorry.
Massive is offline   Reply With Quote
Old 06-25-2003, 12:08 PM   #2
Unregistere1
Guest
 
Posts: n/a
You can't use recv() to do that.

Either use a length indicator at the start of the data, or a end of data marker (like \0 or \n).

Read here too.
  Reply With Quote
Old 06-25-2003, 12:09 PM   #3
Unregistere1
Guest
 
Posts: n/a
Eh, the link is actually:
Quick Winsock question
  Reply With Quote
Old 06-25-2003, 12:33 PM   #4
Registered User
 
Join Date: Jun 2003
Posts: 31
ok i understand, but if i'm sending a binary file ?? it's a problem to put a terminator character...
don't think??
Massive is offline   Reply With Quote
Old 06-26-2003, 01:14 AM   #5
Registered User
 
Join Date: Jun 2003
Posts: 31
yes but i would to use non blocking socket and in this way the recv is blocking (or similat to blocking socket).....
Massive is offline   Reply With Quote
Old 06-26-2003, 04:58 AM   #6
End Of Line
 
Hammer's Avatar
 
Join Date: Apr 2002
Posts: 6,240
Quote:
Originally posted by Massive
yes but i would to use non blocking socket and in this way the recv is blocking (or similat to blocking socket).....
The recv() will block whilst it is waiting for data. Once it has received some, it will return and your program continues. If all the data has been received is up to you to determine.

TCP/IP is a stream based protocol, meaning you get the data in whatever sized chunks the OS feels like giving them to you.
__________________
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Hammer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C Sockets - recv() problem Mercurius Networking/Device Communication 3 05-15-2006 07:49 AM
Laptop Problem Boomba Tech Board 1 03-07-2006 06:24 PM
Sorting problem.. well actually more of a string problem fatdunky C Programming 5 11-07-2005 11:34 PM
half ADT (nested struct) problem... CyC|OpS C Programming 1 10-26-2002 08:37 AM
stream socket problem WL C Programming 2 10-01-2001 11:07 PM


All times are GMT -6. The time now is 04:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22