LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 06: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, 09:14 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,351

Rep: Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382Reputation: 5382
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 09:19 AM.
 
Old 09-15-2010, 12:45 AM   #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


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

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

All times are GMT -5. The time now is 06:25 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