Networking Forums

Networking Forums > Computer Networking > Linux Networking > Pros and Cons of using INADDR_ANY vs the ip addr of the machine

Reply
Thread Tools Display Modes

Pros and Cons of using INADDR_ANY vs the ip addr of the machine

 
 
mshetty@mail.com
Guest
Posts: n/a

 
      12-07-2005, 02:02 PM
Hi,

I have a socket program which has to ignore broadcasts (255.255.255.255
as well as 192.168.75.255). In other words the server should only
accept/process requests that were directly sent to it (192.168.75.84).

One way to do it is to to use IP_RECVDSTADDR. Trying to get a simpler
way of doing it..

While testing I noticed that broadcasts are received only when the
server binds to INADDR_ANY and not when it binds to 192.168.75.84.

My knowledge of sockets is limited. Kindly let me know if my
understanding is correct.

The server is running on a non-multihomed machine (has only 1 ip) in
such situation are there drawbacks of using the ip versus using
INADDR_ANY?

I mean if I used the ip then would I encounter any problems like not
being able to receive certain type of requests...?

Would help if I could get any information on this.

Thanks and Regards,
M Shetty

 
Reply With Quote
 
 
 
 
Barry Margolin
Guest
Posts: n/a

 
      12-08-2005, 03:20 AM
In article <(E-Mail Removed). com>,
(E-Mail Removed) wrote:

> The server is running on a non-multihomed machine (has only 1 ip) in
> such situation are there drawbacks of using the ip versus using
> INADDR_ANY?
>
> I mean if I used the ip then would I encounter any problems like not
> being able to receive certain type of requests...?


You won't be able to receive requests sent from the server machine to
"localhost", since this is 127.0.0.1. If you want to handle that as
well, open a second socket and bind it to this address.

You can also handle multihomed machines by looping through all the
interfaces and binding a socket to each one. This will get the
localhost address automatically, so you won't need to special-case it.

--
Barry Margolin, (E-Mail Removed)
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pros and Cons of using ftp vs. rsync? Goran Ivanic Linux Networking 14 05-06-2008 03:53 PM
NFS vs. Samba - pros & cons? Charlie Gibbs Linux Networking 4 03-03-2008 08:18 PM
pros cons of upnp ? scott Windows Networking 0 03-29-2006 10:32 AM
UPnP On or Off Pros/Cons? MN-700 BRIAN J Broadband Hardware 1 06-28-2004 09:16 PM
ICS vs router - pros and cons? Tiny Tim Home Networking 6 12-03-2003 09:51 PM



1 2 3 4 5 6 7 8 9 10 11