Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Setting Socket.ReceiveBufferSize

Setting Socket.ReceiveBufferSize

Scheduled Pinned Locked Moved C#
comsysadminperformancequestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HosamAly
    wrote on last edited by
    #1

    Hello, Are there side effects of setting Socket.ReceiveBufferSize to a large value (e.g. 50 MB)? I am writing an application to receive and process a large amount of data. Instead of writing code to read data asynchronously, I was thinking of setting Socket.ReceiveBufferSize to a large number. I am not worried about consuming system resources since the program will run on a dedicated machine. However, I am not sure whether this might have a negative effect over performance, or any other side effects that I should take care of. FWIW, my application simply uses StreamReader.ReadLine() over the socket's network stream. Thanks a lot :)

    My LinkedIn Profile

    M 1 Reply Last reply
    0
    • H HosamAly

      Hello, Are there side effects of setting Socket.ReceiveBufferSize to a large value (e.g. 50 MB)? I am writing an application to receive and process a large amount of data. Instead of writing code to read data asynchronously, I was thinking of setting Socket.ReceiveBufferSize to a large number. I am not worried about consuming system resources since the program will run on a dedicated machine. However, I am not sure whether this might have a negative effect over performance, or any other side effects that I should take care of. FWIW, my application simply uses StreamReader.ReadLine() over the socket's network stream. Thanks a lot :)

      My LinkedIn Profile

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      What do you hope to gain by setting the receive buffer size that large? Even if the system lets you do it, it will most likely hurt performance. Why not try it and see what happens? :) Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      H 1 Reply Last reply
      0
      • M Mark Salsbery

        What do you hope to gain by setting the receive buffer size that large? Even if the system lets you do it, it will most likely hurt performance. Why not try it and see what happens? :) Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        H Offline
        H Offline
        HosamAly
        wrote on last edited by
        #3

        By setting the receive buffer so large, I am hoping to avoid having to read data in a thread and process it in another one. At certain (and few) instances of time, I will be receiving 3X data, where X is the amount of data I can process per second. However, right following that, there will be 0.1X data for some time. So, instead of having to synchronize reader and processor threads, I was hoping the system buffer could just hold the additional data for me. Meanwhile, I don't think I can test performance right now, because there are many other factors that I might not be able to control. So, why do you think it would hurt performance? Thanks for your help.

        My LinkedIn Profile

        M 1 Reply Last reply
        0
        • H HosamAly

          By setting the receive buffer so large, I am hoping to avoid having to read data in a thread and process it in another one. At certain (and few) instances of time, I will be receiving 3X data, where X is the amount of data I can process per second. However, right following that, there will be 0.1X data for some time. So, instead of having to synchronize reader and processor threads, I was hoping the system buffer could just hold the additional data for me. Meanwhile, I don't think I can test performance right now, because there are many other factors that I might not be able to control. So, why do you think it would hurt performance? Thanks for your help.

          My LinkedIn Profile

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          AFAIK, Windows Sockets will let you set it to a max size of 1MB. The receive buffer isn't meant to be a data store. For best TCP/IP performance, your user-mode code should remove ("receive") data from the socket ASAP. i.e. Send buffer should be full, receive buffer should be empty.

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups