maximum data (bytes) send via socket ???

This is a discussion on maximum data (bytes) send via socket ??? within the C Programming forums, part of the General Programming Boards category; The title is my question ???...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    _jr
    _jr is offline
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,192
    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-07-2007, 11:24 PM
  2. Cannot read incoming data from socket
    By fnoyan in forum C++ Programming
    Replies: 6
    Last Post: 03-06-2006, 01: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, 05:03 PM

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