First of all, TCP is not stream oriented. It is a protocol that requires a connection with a remote host. The IP protocol is a windowing protocol (in contrast to an old ack/nak protocol). Data sent via IP is transparent as the '\n' has no meaning. There is really no concept of a line in Linux WRT communications. Essentially a line is just some data with a '\n'. I suggest you consult a good book on Unix/Linux network programming, such as /UNIX Network Programming/, by the late W. Richard Stephens. This was at one time the best set of books. I think that this can answer all your questions. In the past I wrote a satellite communications system using either TCP or UDP based on lines. The issue is not so much the IP, TCP or UDP protocols, but how the end-user application handles the data. On 09/30/2010 09:57 AM, Roger Oberholtzer wrote:
TCP is of course stream oriented. It does not have a concept of lines. Serial ports, of course, can be configured as stream, line, character, whatever.
I have a function that I want to make work on either a serial or a TCP port. I want this to be line oriented. Of course, I know how to do this reading a character at a time and taking appropriate action.
On the other hand:
On the serial port I can arrange it so reads are satisfied when there is a whole line. That is, each read returns only when a whole line is available.
My question: Is there some obscure TCP ioctl() that would let me get the same for TCP streams? I have looked, and I do not see anything in the standard Linux networking docs. I don't really expect that there is such a mode, but I thought I would ask around a bit before doing the character-at-a-time thing.
TIA for any pointers.
--
Jerry Feldman