Socket programming doubts

I am currently going over beej's tutorial for network programming. I wanted to clarify a few things ?

1) Can multiple writes/sends result in a single receive/read ? and the other way round? So does that mean , we need to have some sort of a protocol wrapper over tcp ?

2) Is there any problem sending structures over two similar systems? Or is TCP suited only for stream data ? i.e it does mention problems sending floats ,ints etc... but shouldnt that be between two different systems (little/big endian)?

Thanks!
1) Yes, data will be received in arbitrarily sized chunks.

So does that mean , we need to have some sort of a protocol wrapper over tcp ?
Not sure what you mean by that, but you always need some sort of protocol.

2) You can never send structures that contain pointers directly or indirectly.
You'll have a much easier life if you properly serialize your data and choose a byte order for it.

Or is TCP suited only for stream data ?
What is "stream data"?

but shouldnt that be between two different systems (little/big endian)?
If both systems use the same byte order and the same floating point layout, there should be no problems.
TCP is a stream protocol, which means you have to put some kind of protocol on top. There's nothing in TCP to indicate end of record/end of anything.

You have to encode machine specific things in a more general way. For example floats. Plus there's the endian issue. Check out XDR for one possible solution.
Topic archived. No new replies allowed.