recv() problem

This is a discussion on recv() problem within the C Programming forums, part of the General Programming Boards category; in i simple program that use sockets how can i know if the recv() function has received all data ??? ...

  1. #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.

  2. #2
    Unregistere1
    Guest
    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.

  3. #3
    Unregistere1
    Guest
    Eh, the link is actually:
    Quick Winsock question

  4. #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??

  5. #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).....

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    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]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Sockets - recv() problem
    By Mercurius in forum Networking/Device Communication
    Replies: 3
    Last Post: 05-15-2006, 08:49 AM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  3. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 09:37 AM
  5. stream socket problem
    By WL in forum C Programming
    Replies: 2
    Last Post: 10-02-2001, 12:07 AM

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