LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2010, 05:49 AM   #1
mandeep.singh.bhatia
LQ Newbie
 
Registered: Apr 2010
Location: Delhi, India
Distribution: openSuse
Posts: 6

Rep: Reputation: 0
about linux sendto


Hi,
I just need to get this clarified. When we send character data buffer with sento over udp socket, does sendto make a copy of the buffer or does it just take the pointer and size and send the data buffer from pointed location.
I ask this for understanding that would it be legal or illegal to allocate a memory buffer then call sendto in non-block mode and then immediately delete the allocated memory, or, a case where we keep a common buffer and in a loop change the value of buffer and call sendto.
Regards,
Mandeep
 
Old 09-14-2010, 08:14 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,222

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
If it sent a pointer, then how would the remote machine be able to access the data? The remote machine can't read memory on the local machine.

I haven't actually checked this, but I think it must send a copy of the buffer.

Last edited by dugan; 09-14-2010 at 08:19 AM.
 
Old 09-14-2010, 11:45 PM   #3
mandeep.singh.bhatia
LQ Newbie
 
Registered: Apr 2010
Location: Delhi, India
Distribution: openSuse
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by dugan View Post
If it sent a pointer, then how would the remote machine be able to access the data? The remote machine can't read memory on the local machine.

I haven't actually checked this, but I think it must send a copy of the buffer.
Hi, actually I meant that the sendto might just read from the buffer location via the pointer passed and send out data directly from the pointed buffer instead of making its own copy. I wanted to be sure of what is happening and how it happens.
Regards,
Mandeep
 
  


Reply

Tags
nonblocking, udp



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
IPv6 Linux sendto() problems eponymous Linux - Software 5 09-11-2011 01:15 PM
[SOLVED] sendto doesn't send right away? homer_3 *BSD 1 08-07-2010 04:38 PM
Networking, sendto() dmiller Programming 1 04-01-2010 07:50 PM
sendto hangs digvijay.gahlot Linux - Networking 0 04-24-2009 08:22 AM
how to sendto() on packet sockets in linux? kiba Programming 3 10-29-2003 11:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:55 PM.

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