James said:
*Like* Ethernet MTU constraints... or UDP, or whatever. I could
have worded that better.
Ethernet is a data link technology. IP runs on top of data link
systems such as Ethernet and adds unreliable datagram communication. This
permits sizes up to 64k.
Badly. I would avoid this if I were you. Google for "Fragmentation
considered harmful"
I am sure there are PHY layers such that 64 k byte as an MTU
isn't a problem. At that point, go for it.
More importantly, TCP runs on top of IP and adds
both reliability and a stream model.
But this is *also* problematic. If you use blocking sockets, then
you are subject to the whims of whatever it is that is
unreliable between you and the far end.
If you use nonblocking sockets, you get a piece at a time
and get to do your own reassembly.
And when you use *blocking* sockets, you may well *hang*
on a read() ioctl() at embarrassing times. This may well
require a full-on reboot.
Hence "when it's a buffer"....
The stream model makes apps communicate
octet streams without regard to packet or datagram sizes.
Not in actuality.
So any app which
uses TCP can pass long strings to other processes. It is not limited by the
1500 or 64k limits.
SO you have two choices - either treat "unlimited stream size" as a
natural right, and then have to go fix it when this assumption fails,
or understand the lower layers and plan accordingly.
I know which one I do...
Note the Total Length field in the IP header
https://en.wikipedia.org/wiki/IPv4_header#Header
and the 32-bit sizes of the Syn and Ack fields in the TCP header
https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure
Absolutely.
The point is that Ethernet MTUs do not limit the sizes of strings that
programs can send to one another. UDP will not but TCP will split a very
long string into datagrams as needed.
This entire line of argument *ignores* that I still have to wonder
why anybody needs 1 megabyte strings - that subsequently require
some sort of string manipulation - in the first place.