1#ifndef __JNET__JSOCKETADDRESS__
2#define __JNET__JSOCKETADDRESS__
16namespace JPP {
using namespace JNET; }
35 bzero((
char*) &(*
this),
sizeof(sockaddr_in));
46 return (
const sockaddr*)
static_cast<const sockaddr_in*
>(
this);
57 return (sockaddr*)
static_cast<sockaddr_in*
>(
this);
101 return sin_addr.s_addr;
112 sin_addr.s_addr = ip_number;
121 sin_addr.s_addr = htonl(INADDR_ANY);
132 return ntohs(this->sin_port);
143 if (port >= 0 && port <= std::numeric_limits<u_short>::max())
144 sin_port = htons((u_short) port);
157 return sizeof(sockaddr_in);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Hostname and IP address functions.
Exception for cast operation.
The JSocketAddress class encapsulates the sockaddr_in data structure.
int getIPnumber() const
Get IP number.
std::string getHostname() const
Get host name.
void setFamily(const int family)
Set family.
int getPort() const
Get port number.
const sockaddr * getSockaddr() const
Get sockaddr.
void setIPnumber()
Set any IP number.
int getFamily() const
Get family.
sockaddr * getSockaddr()
Get sockaddr.
JSocketAddress()
Default constructor.
void setIPnumber(const int ip_number)
Set IP number.
void setPort(const int port)
Set port number.
static int sizeOf()
Get size of object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::string getHostname()
Get host name.