Thread: maximum data (bytes) send via socket ???

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    8

    Question maximum data (bytes) send via socket ???

    The title is my question ???

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by tritong
    The title is my question ???
    There is no maximum number of bytes that can be sent through a socket. Bytes are put together into "packets", and transmitted (usually), as such, according to the format that's being used.

    If you want to know the size and spec's of the TCP/IP protocol/format, generally used on the internet, you'll need to either google it, or go to an internet communication forum or newsgroup.

    It's not a part of the C language.

    Good luck.

    Adak

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > maximum data (bytes) send via socket ?
    You mean in a single call to send() ?

    You can send as many as you like, but you must look at the return result to find out how many were actually sent. Then call send() again with the remainder of the buffer until all of your data is sent (or until send returns an error)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    10

    hmm

    While TCP stream does not preserve boundary, UDP does, so 1 UDP send() == 1 UDP receive(), and afaik (and I can be wrong) a single UDP message (send()) may be no more 65k in size....
    Last edited by _jr; 09-18-2006 at 08:19 AM.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    8
    Code:
    int rc = write(socket, str, strlen(str));
    maximum can use (strlen(str)) = ?
    Does it greater than 4096 ???

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    What have you tried already?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    strlen() returns a value of type size_t. The maximum value that can be stored in a size_t is implementation dependent (i.e. depends on your compiler and target machine). Read the documentation for your compiler, and you will be able to find what that maximum is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  2. Cannot read incoming data from socket
    By fnoyan in forum C++ Programming
    Replies: 6
    Last Post: 03-06-2006, 02:42 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  5. can't insert data into my B-Tree class structure
    By daluu in forum C++ Programming
    Replies: 0
    Last Post: 12-05-2002, 06:03 PM