LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-20-2010, 03:08 AM   #1
fjkum
Member
 
Registered: Feb 2006
Posts: 40

Rep: Reputation: 15
Use send() instead of sendto() for UDP


Hi,

Can I use send() function to send UDP datagram through a socket instead of calling the sendTo()?
 
Old 01-20-2010, 06:14 AM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Hey,

it would help to check the man page for the send(2) system call.

"The send() call may be used only when the socket is in a connected state (so that the intended recipient is known)." As per definition, UDP is never in a connected state, so that you can't use send(2) instead of sendto(2).

- Andi -
 
Old 01-20-2010, 10:16 PM   #3
fjkum
Member
 
Registered: Feb 2006
Posts: 40

Original Poster
Rep: Reputation: 15
Ah okay, that explains why I still can use send(); that's because my implementation of UDP is a "connected" state by calling to connect() before send().

Thanks!
 
  


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
sendto function call in UDP client program chakka.lokesh Programming 1 01-05-2010 10:53 PM
C++ Multicast UDP send with errno 11 kurtwagner Programming 4 05-07-2009 02:41 AM
Multithread udp socket client fails to sendto data dilin Programming 0 04-06-2007 09:07 AM
wireless card udp sendto() question ggeorgak Programming 1 02-11-2007 10:26 AM
Why does Samba send malformed UDP packets to 137 and 138? The Dartman Linux - Networking 2 04-12-2004 03:28 PM

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

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