Sponsored Content
Full Discussion: Inaddr_any
Special Forums IP Networking Inaddr_any Post 21798 by killerserv on Thursday 23rd of May 2002 01:53:37 AM
Old 05-23-2002
Im not sure clearly what your question is, but i will give a try.
INADDR_ANY has the following semantics, When receiving, a socket bound to the address receives packets from all interfaces. For example, suppose that a host has interfaces 0, 1 and 2. If a UDP socket on this host is bound using INADDR_ANY and udp port 8000, then the socket will receive all packets for port 8000 that arrive on interfaces 0, 1, or 2. If a second socket attempts to Bind to port 8000 on interface 1, the Bind will fail since the first socket already "owned'' that port/interface. When sending, a socket bound with INADDR_ANY binds to the default IP address, which is that of the lowest-numbered interface.
 

2 More Discussions You Might Find Interesting

1. IP Networking

INADDR_ANY opposite

Hello, is there some way to obtain system's IP adresses to bind socket to every of them separately instead od INADDR_ANY? OR If there is some way to get server's IP to which client has connected, for example: server_app - bind to listen on INADDR_ANY, gets connected client to 1.2.3.4,... (2 Replies)
Discussion started by: d4rkl0rd
2 Replies

2. IP Networking

UDP server socket inaddr_any - How to get the real IP

Hello ! I seem to have the same problem as in https://www.unix.com/ip-networking/91203-inaddr_any-opposite.html#post302262417 But I can't find a solution. I have a UDP server socket bound to 0.0.0.0. The server hosts the addresses IP1, IP2 and IP3. I get an incoming request to IP1. I use... (1 Reply)
Discussion started by: steinwej
1 Replies
UDP(4P) 																   UDP(4P)

NAME
udp - Internet User Datagram Protocol SYNOPSIS
#include <sys/socket.h> #include <netinet/in.h> s = socket(AF_INET, SOCK_DGRAM, 0); DESCRIPTION
UDP is a simple, unreliable datagram protocol which is used to support the SOCK_DGRAM abstraction for the Internet protocol family. UDP sockets are connectionless, and are normally used with the sendto and recvfrom calls, though the connect(2) call may also be used to fix the destination for future packets (in which case the recv(2) or read(2) and send(2) or write(2) system calls may be used). UDP address formats are identical to those used by TCP. In particular UDP provides a port identifier in addition to the normal Internet address format. Note that the UDP port space is separate from the TCP port space (i.e. a UDP port may not be "connected" to a TCP port). In addition broadcast packets may be sent (assuming the underlying network supports this) by using a reserved "broadcast address"; this address is network interface dependent. Options at the IP transport level may be used with UDP; see ip(4P). DIAGNOSTICS
A socket operation may fail with one of the following errors returned: [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destina- tion address specified and the socket is already connected; [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected; [ENOBUFS] when the system runs out of memory for an internal data structure; [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated; [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. SEE ALSO
getsockopt(2), recv(2), send(2), socket(2), intro(4N), inet(4F), ip(4P) 4.2 Berkeley Distribution May 16, 1986 UDP(4P)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy