HI,Socket on ethernet: Is it possible to have two send() with 5 octets evryone and have a recv()with 10 octets recieved? If it is possible, do you now a technique for separate evry send() wihtout a active scan on the recieve buffer?
Since this is in the Network API forum, I assume you want to use TCP/IP calls. Let me lay some groundwork here. UDP is a packet based protocol. If you give send() a five byte packet, the matching receive() will return a five byte packet. You will have to do one receive() call for each send() call. However, delivery is not guaranteed, so you may need to detect and handle dropped packets in your application. TCP is a stream protocol. It guarantees delivery of data in the same order as it was sent, or you will get an error at the sender. But it implies no structure. So a read() will return whatever is available in the buffers at that instant, up to the maximum size of the buffer you passed. It is up to your application to impose any structure on that data. Depending on the stack implementations and buffer sizes on each end, the data may be broken up in any size packets, or even in apparently random sized packets when you look at it with a sniffer. The receiving stack will reassemble it in the correct order before the application gets it. So it is up to the application to determine when it needs to call read() to get more data before processing. Hope this helps, Bob