CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2004
    Posts
    391

    message lengths Winsock2 TCp/Ip

    hi,

    are there any general guidlines for the size of a message that should be send over TCP/Ip using winsock2. e.g I have a structue of max size 3461760 bytes. Can be be sent over tcp/ip as a message to an application as one single message.

    What are the issues with using recv ( winsock2 ) and datalengths, if there are any.

    Can anyone point me to a an article which can explain this. I am new to network programmign basically with zero training and have to research on my own to write a set of network applications.

    Thnx for help.

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757

    Re: message lengths Winsock2 TCp/Ip

    Interesting.

    check out getsockopt() and SO_SNDBUF. i read something about 8192 default buffer size

    Kuphryn

  3. #3
    Join Date
    Aug 2004
    Posts
    391

    Re: message lengths Winsock2 TCp/Ip

    isn't this one for unix thou? all the articles abt it mention unix. My apps are gonan run on windows and use winsock2

  4. #4
    Join Date
    Aug 2004
    Posts
    391

    Re: message lengths Winsock2 TCp/Ip

    sorry yeah it is for winsock too.

    Okie let's assume that the data i wanna send is larger then that value. How do you deal witht his kinda thing when the message is recieved by client/server? am tempted to use recv( well dunno abt anything else )

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: message lengths Winsock2 TCp/Ip

    Quote Originally Posted by venAdder
    are there any general guidlines for the size of a message that should be send over TCP/Ip using winsock2. e.g I have a structue of max size 3461760 bytes. Can be be sent over tcp/ip as a message to an application as one single message.
    yes, the buffer can be sent all at once, with one call to send(). This is a simple technique usable when there is only one (or, at most a few) transmissions, such as between a single server and a single client.

    This approach does not scale well, however, if there are many transmission (or many clients being served), since then you must allocate many large-sized buffers. so, in this case, one approach is to break the transmission into blocks of reasonable size, and send only one block at a time. The definition of "reasonable" will vary based on your specific application. Frequently-used numbers are 4k and 8k.

    Quote Originally Posted by venAdder
    What are the issues with using recv ( winsock2 ) and datalengths, if there are any.
    Same issue as above (memory allocation for the receive buffer), plus another: responsiveness. If you try to receive one single huge buffer, then you will typically wait until the entire buffer is received, which might take a long time during which nothing else happens. On the other hand, if you receive multiple smaller buffers, then at least something is happening periodically, such as the accumulation of a received file to permanent storage on a disk.

    Quote Originally Posted by venAdder
    Can anyone point me to a an article which can explain this. I am new to network programmign basically with zero training and have to research on my own to write a set of network applications.

    Thnx for help.
    I listed a few links at your other post.

    Mike

  6. #6
    Join Date
    Aug 2004
    Posts
    391

    Re: message lengths Winsock2 TCp/Ip

    Thanx Mike, it did help me a lot , I am gonan keep exploring into this till i get it all straightened out . Thnx again for you help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured