Skip to main content

TCP Segment Limits

info

NetShield does not read your data by design. This gives you complete freedom to use the data in the way that you'd like, without having to stick it into an annoying NetShield-specific protocol/be forced to add length attributes.

Your strings might be longer than the (default) package size for the server/client involved. TCP segments can generally carry 1448 bytes by default (your configuration may have longer/smaller packet sizes). If your string is longer than this, it will be split over multiple segments/packets, which might arrive to your game at a different point in time. NetShield periodically checks for new data (and will trigger the event when it detects it), but does not know anything about the data itself: that's your (protocol's) responsibility.

If you think this may be causing your problems, consider adding a length attribute or end of message token to your message. If the data NetShield presents to you isn't the correct length or doesn't contain this token, add it to a buffer and wait for more data to arrive.

NOTE: This can also be useful for the reverse problem, where if you send a lot of small bits of data, it may end up being received at the same time: it's your protocol's responsibility to tell these messages apart, which can be done using the techniques described above.

Want to learn more? Check out this awesome writeup by the Code Project