Like Tree1Likes
  • 1 Post By anduril462

send len size

This is a discussion on send len size within the Networking/Device Communication forums, part of the General Programming Boards category; That may sound like a beginner question but if the third param is an 'int', it means I cannot put ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    756

    send len size

    That may sound like a beginner question but if the third param is an 'int', it means I cannot put there a number greater than 2,147,483,647.
    So a 'long' is out of the question?

    Code:
    int send(   __in  SOCKET s,   __in  const char *buf,   __in  int len,   __in  int flags );
    Compiler MSVC++ 2010 with Code::Blocks.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,444
    Yes, a long is out of the question, since long and int are two different types. According to the standard, an int must have a range of at least -32,768 to 32,767, but can be larger. A long is guaranteed to contain at least +/- 2 billion, but could also be larger. On 32 bit systems, an int it is typically implemented as +/- 2 billion anyways (+/- 2^31). On 64-bit systems, an int it's usually larger (+/- 2^63). So on a 64-bit system, you could potentially pass 9 quadrillion (~9x10^18) bytes as a length parameter.

    But all of that is a moot point, really. The kernel buffers that actually marshal the data to send on the socket aren't that big, and the sockets themselves just can't handle 2GB worth all at once. Send in reasonably-sized chunks. Something on the order of kilobytes would be good.
    Ducky likes this.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    756
    Thanks for the thorough explanation.
    Compiler MSVC++ 2010 with Code::Blocks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. size of array - why function gives size ONE only
    By noob123 in forum C++ Programming
    Replies: 7
    Last Post: 12-18-2009, 04:20 PM
  2. Size of fixed size object?
    By shwetha_siddu in forum C Programming
    Replies: 2
    Last Post: 04-08-2009, 02:39 AM
  3. Finding Words in a array[size][size]
    By ^DJ_Link^ in forum C Programming
    Replies: 8
    Last Post: 03-08-2006, 02:51 PM
  4. window size VS. pixel size
    By dug in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2003, 06:30 AM
  5. Determining Data Size For Network Send/Rec :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 6
    Last Post: 05-07-2002, 09:01 PM

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