LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Reading a Socket With the Recv() Function (https://www.linuxquestions.org/questions/linux-networking-3/reading-a-socket-with-the-recv-function-4175447684/)

Brandon9000 01-29-2013 07:43 AM

Reading a Socket With the Recv() Function
 
When using Internet sockets, the recv() function has the form:

ssize_t recv(int socket, void *buffer, size_t length, int flags).

I am concerned about what happens if a single read brings in more data than the size of the buffer. I know that for UDP sockets, any data in excess of the length parameter will be discarded. I cannot find a straight answer to the question of what happens for TCP sockets when more data arrives than the buffer length. Does anyone know?

Thanks!

linosaurusroot 01-30-2013 06:19 AM

It's like reading a file. The remaining data is still present awaiting your next read()/recv().

Brandon9000 01-30-2013 07:34 AM

Good, then it won't overflow the buffer if the length parameter has been given correctly. Thank you.


All times are GMT -5. The time now is 08:09 AM.