Go to the documentation of this file. 1 #ifndef __JNET__JSOCKETADDRESS__
2 #define __JNET__JSOCKETADDRESS__
4 #include <netinet/in.h>
16 namespace 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);
void setIPnumber(const int ip_number)
Set IP number.
static int sizeOf()
Get size of object.
Exception for cast operation.
JSocketAddress()
Default constructor.
std::string getHostname() const
Get host name.
const sockaddr * getSockaddr() const
Get sockaddr.
Interprocess communication.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
void setIPnumber()
Set any IP number.
int getPort() const
Get port number.
void setFamily(const int family)
Set family.
sockaddr * getSockaddr()
Get sockaddr.
int getIPnumber() const
Get IP number.
std::string getHostname()
Get host name.
The JSocketAddress class encapsulates the sockaddr_in data structure.
void setPort(const int port)
Set port number.
int getFamily() const
Get family.