Re: socket's address binding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 22 Mar 2005, Filipe Abrantes wrote:

When I don't bind an UDP socket to a specific local IP address, that socket may receive packets from any interface.

Yes.

But imagine that one IP address of one of my local interfaces changes, will I be able to continue receiveing packets from that interface using the previous socket?

Yes, provided you have not explicitly bound it to a specific IP which no longer exists.


What does the kernel do when I create a socket without binding it to a local IP address, does it bind it to all my IP's at the time the socket was created?

No, it just binds to the port, leaving the IP unspecified matching all IPs which exists or will exists on the host now and in the future.


On a related note you can also specify which interface to bind the socket to by using SO_BINDTODEVICE, as described in man 7 socket.

Regards
Henrik
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux