Search code examples
socketspollingepollpackets

Does ppoll aggregate packets?


Does ppoll() aggregate packets? I have a socket library I built that works great with low throughput. However when I start to increase the number of messages i begin to see packet size increases. I checked the sender size and all the packets the sender sends are correct. When the recv() fucntion is called the packets begin to max out and causes the app to fault. Any clues?


Solution

  • ppoll() doesn't aggregate packets, but the socket receive buffer does, and so does the socket send buffer at the sender. You cannot rely on receive counts in TCP: there are no messages, and boundaries between writes at the sender are not preserved at the receiver. It is strictly a byte-stream. Any packetization is entirely up to you to implement.

    When the recv() fucntion is called the packets begin to max out and causes the app to fault.

    Only if you have a bug in your code. Typical errors include:

    • assuming that recv() did or didn't fill the buffer
    • sticking a null at the end of the buffer to null-terminate it for string handling, which won't work if the buffer was filled
    • assuming there wasn't an error, or wasn't end of stream
    • ignoring the count returned by recv() altogether.