Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-29-2013, 07:43 AM   #1
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Rep: Reputation: Disabled
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?

Old 01-30-2013, 06:19 AM   #2
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
It's like reading a file. The remaining data is still present awaiting your next read()/recv().
Old 01-30-2013, 07:34 AM   #3
Registered: Apr 2012
Location: Florida
Distribution: Many
Posts: 111

Original Poster
Rep: Reputation: Disabled
Good, then it won't overflow the buffer if the length parameter has been given correctly. Thank you.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get source IP from UDP socket using recv() Lantzvillian Programming 3 09-29-2010 05:20 PM
Simultaneous Socket Send/Recv in Perl? juanbobo Programming 10 07-28-2008 03:30 AM
recv() and send() in socket lrios Programming 5 04-23-2008 11:32 AM
recv() function of SOCKET ashucool83 Programming 1 10-08-2005 07:38 PM
function recv() in socket husniteja Programming 1 08-18-2004 09:06 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration