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 11-29-2010, 10:27 PM   #1
rbdavis
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Rep: Reputation: 3
using INADDR_ANY with UDP


I have a question about the interpretation of INADDR_ANY in conjunction with UDP. I have seen various questions and explanations about INADDR_ANY but none seem to quite match my exact circumstances, so I'm hoping someone can give me a clear explanation that applies to my particular applications. My understanding is that INADDR_ANY has different semantics depending upon whether you are a server or client, but since this is UDP and there is not any ongoing connection I'm not sure how that model applies to me.

We have various UDP talker processes on different machines on the network which write UDP datagrams containing data of interest, sometimes addressed to a particular host (e.g., xxx.xxx.xxx.someHostNumber) and sometimes addressed to the broadcast address (e.g., xxx.xxx.xxx.255). My listener process wants to receive these datagrams, possibly from multiple sources, on a machine with multiple Ethernet interfaces. If my listener does a bind() on some specific port number P using a sockaddr that has been set to INADDR_ANY, exactly what is that supposed to do? More particularly, if that socket then does a series of read()s, does it (1) read all packets addressed to port P on any of the interfaces, (2) read only packets addressed to port P on the default interface 0, (3) read the first packet addressed to port P on any of the interfaces and thereafter read only packets from the first interface where it saw a packet addressed to P, or perhaps something else entirely?

Thanks!

Roger Davis
 
Old 11-29-2010, 11:07 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
With INADDR_ANY, the socket binds to all interfaces on the system. You will see all packets with destination port P on any interface.
 
Old 11-29-2010, 11:12 PM   #3
rbdavis
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Original Poster
Rep: Reputation: 3
Thanks, David!

Roger
 
  


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
binding to a socket with INADDR_ANY, can i find which ip is being connected to? nkoplm Programming 3 12-06-2009 12:17 AM
INADDR_ANY with IP_ADD_MEMBERSHIP & IP_MULTICAST_IF giving error Linuxfan0001 Linux - Networking 0 01-29-2009 04:30 AM
uknown url type udp when using a udp tracker fakie_flip Linux - Software 1 08-03-2006 05:03 AM
UDP: Short Packets: and UDP bad checksum: entries in dmesg minutes2memories Linux - Networking 2 02-26-2006 07:28 PM
How to receive UDP and ICMP packets, by one UDP socket(PMTUD) myself_rajat Linux - Networking 0 05-28-2004 05:43 AM

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

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