nidas
v1.2-1520
|
A IP version 4 socket address, containing a host address, and a port number. More...
#include <Inet4SocketAddress.h>
Public Member Functions | |
Inet4SocketAddress () | |
Default constructor, address of 0.0.0.0 (INADDR_ANY), port 0. More... | |
Inet4SocketAddress (int port) | |
Address of 0.0.0.0 (INADDR_ANY), with a given port number. More... | |
Inet4SocketAddress (const Inet4Address &, int port) | |
Inet4SocketAddress (const struct sockaddr_in *_sockaddr) | |
Inet4SocketAddress (const Inet4SocketAddress &) | |
Copy constructor. More... | |
Inet4SocketAddress & | operator= (const Inet4SocketAddress &x) |
Assignment operator. More... | |
Inet4SocketAddress * | clone () const |
Virtual constructor. More... | |
int | getFamily () const |
Return the address family, AF_INET. More... | |
int | getPort () const |
Return the port number. More... | |
void | setPort (int val) |
Set the port number. More... | |
Inet4Address | getInet4Address () const |
Return the IP address portion. More... | |
struct sockaddr * | getSockAddrPtr () |
Provide non-const pointer to struct sockaddr_in. More... | |
struct sockaddr * | getConstSockAddrPtr () const |
Provide const pointer to struct sockaddr_in. More... | |
socklen_t | getSockAddrLen () const |
Return the length of the struct sockaddr_XX for this address family. More... | |
std::string | toString () const |
Java style toString: returns "inet:hostname:port". More... | |
std::string | toAddressString () const |
Java style toString, but no DNS lookup: returns "inet:w.x.y.z:port". More... | |
bool | operator< (const Inet4SocketAddress &x) const |
Comparator operator for addresses. More... | |
bool | operator== (const Inet4SocketAddress &x) const |
Equality operator for addresses. More... | |
Protected Attributes | |
struct sockaddr_in | _sockaddr |
A IP version 4 socket address, containing a host address, and a port number.
The only data element is a struct sockaddr_in, so the default copy constructor and assignment operators work fine.
Inet4SocketAddress::Inet4SocketAddress | ( | ) |
Inet4SocketAddress::Inet4SocketAddress | ( | int | port | ) |
Address of 0.0.0.0 (INADDR_ANY), with a given port number.
References _sockaddr.
Inet4SocketAddress::Inet4SocketAddress | ( | const Inet4Address & | addr, |
int | port | ||
) |
References _sockaddr, and nidas::util::Inet4Address::getInAddrPtr().
Inet4SocketAddress::Inet4SocketAddress | ( | const struct sockaddr_in * | _sockaddr | ) |
Inet4SocketAddress::Inet4SocketAddress | ( | const Inet4SocketAddress & | x | ) |
Copy constructor.
|
virtual |
|
inlinevirtual |
Provide const pointer to struct sockaddr_in.
Implements nidas::util::SocketAddress.
References _sockaddr.
|
inlinevirtual |
Return the address family, AF_INET.
Implements nidas::util::SocketAddress.
|
inline |
Return the IP address portion.
Referenced by nidas::core::MultipleUDPSockets::addClient(), nidas::core::DatagramSocket::connect(), nidas::util::SocketImpl::getInterface(), nidas::core::Socket::getRemoteInet4Address(), nidas::core::UDPSocketIODevice::open(), nidas::core::DSMServerStat::run(), nidas::util::McSocketListener::run(), nidas::util::McSocketMulticaster< SocketTT >::run(), nidas::dynld::SampleInputStream::setIOChannel(), nidas::core::Socket::Socket(), toAddressString(), and toString().
|
inlinevirtual |
Return the port number.
Implements nidas::util::SocketAddress.
Referenced by nidas::util::McSocket< SocketT >::getInterfaces(), nidas::util::McSocketListener::run(), toAddressString(), and toString().
|
inlinevirtual |
Return the length of the struct sockaddr_XX for this address family.
Implements nidas::util::SocketAddress.
References _sockaddr.
|
inlinevirtual |
Provide non-const pointer to struct sockaddr_in.
This is needed for recvfrom methods. recvfrom updates the struct sockaddr_in, so we can't cache the other portions of the address.
Implements nidas::util::SocketAddress.
References _sockaddr.
bool Inet4SocketAddress::operator< | ( | const Inet4SocketAddress & | x | ) | const |
Comparator operator for addresses.
Useful if this address is a key in an STL map.
References _sockaddr.
Inet4SocketAddress & Inet4SocketAddress::operator= | ( | const Inet4SocketAddress & | x | ) |
Assignment operator.
References _sockaddr.
bool Inet4SocketAddress::operator== | ( | const Inet4SocketAddress & | x | ) | const |
Equality operator for addresses.
References _sockaddr.
|
inline |
Set the port number.
Referenced by nidas::core::MultipleUDPSockets::addClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addConnection(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addDestination(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), and nidas::util::McSocketListener::run().
|
virtual |
Java style toString, but no DNS lookup: returns "inet:w.x.y.z:port".
Implements nidas::util::SocketAddress.
References nidas::util::Inet4Address::getHostAddress(), getInet4Address(), and getPort().
Referenced by nidas::util::McSocketListener::accept(), nidas::core::MultipleUDPSockets::addClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addConnection(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::addDestination(), nidas::core::MultipleUDPSockets::removeClient(), nidas::dynld::UDPSampleOutput::ConnectionMonitor::removeConnection(), and nidas::util::McSocketListener::run().
|
virtual |
Java style toString: returns "inet:hostname:port".
Implements nidas::util::SocketAddress.
References nidas::util::Inet4Address::getHostName(), getInet4Address(), and getPort().
Referenced by nidas::util::McSocket< SocketT >::close(), nidas::util::SocketImpl::getInterface(), nidas::util::McSocket< SocketT >::listen(), nidas::util::McSocket< SocketT >::request(), nidas::util::McSocketListener::run(), and nidas::util::McSocketMulticaster< SocketTT >::run().
|
protected |
Referenced by getConstSockAddrPtr(), getSockAddrLen(), getSockAddrPtr(), Inet4SocketAddress(), operator<(), operator=(), and operator==().