LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2013, 07:43 AM   #1
Brandon9000
Member
 
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?

Thanks!
 
Old 01-30-2013, 06:19 AM   #2
linosaurusroot
Member
 
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
Brandon9000
Member
 
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:26 AM.

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