The JSocketAddress class encapsulates the sockaddr_in
data structure.
More...
#include <JSocketAddress.hh>
The JSocketAddress class encapsulates the sockaddr_in
data structure.
Definition at line 26 of file JSocketAddress.hh.
JNET::JSocketAddress::JSocketAddress |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 33 of file JSocketAddress.hh.
35 bzero((
char*) &(*
this),
sizeof(sockaddr_in));
const sockaddr* JNET::JSocketAddress::getSockaddr |
( |
| ) |
const |
|
inline |
Get sockaddr.
- Returns
- pointer to sockaddr structure
Definition at line 44 of file JSocketAddress.hh.
46 return (
const sockaddr*)
static_cast<const sockaddr_in*
>(
this);
sockaddr* JNET::JSocketAddress::getSockaddr |
( |
| ) |
|
|
inline |
Get sockaddr.
- Returns
- pointer to sockaddr structure
Definition at line 55 of file JSocketAddress.hh.
57 return (sockaddr*)
static_cast<sockaddr_in*
>(
this);
int JNET::JSocketAddress::getFamily |
( |
| ) |
const |
|
inline |
void JNET::JSocketAddress::setFamily |
( |
const int |
family | ) |
|
|
inline |
std::string JNET::JSocketAddress::getHostname |
( |
| ) |
const |
|
inline |
Get host name.
- Returns
- host name
Definition at line 88 of file JSocketAddress.hh.
int getIPnumber() const
Get IP number.
std::string getHostname()
Get host name.
int JNET::JSocketAddress::getIPnumber |
( |
| ) |
const |
|
inline |
Get IP number.
- Returns
- IP number
Definition at line 99 of file JSocketAddress.hh.
101 return sin_addr.s_addr;
void JNET::JSocketAddress::setIPnumber |
( |
const int |
ip_number | ) |
|
|
inline |
Set IP number.
- Parameters
-
Definition at line 110 of file JSocketAddress.hh.
112 sin_addr.s_addr = ip_number;
void JNET::JSocketAddress::setIPnumber |
( |
| ) |
|
|
inline |
Set any IP number.
Definition at line 119 of file JSocketAddress.hh.
121 sin_addr.s_addr = htonl(INADDR_ANY);
int JNET::JSocketAddress::getPort |
( |
| ) |
const |
|
inline |
Get port number.
- Returns
- port number
Definition at line 130 of file JSocketAddress.hh.
132 return ntohs(this->sin_port);
void JNET::JSocketAddress::setPort |
( |
const int |
port | ) |
|
|
inline |
Set port number.
- Parameters
-
Definition at line 141 of file JSocketAddress.hh.
143 if (port >= 0 && port <= std::numeric_limits<u_short>::max())
144 sin_port = htons((u_short) port);
146 THROW(JCastException,
"JSocketAddress::setPort() illegal value.");
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
static int JNET::JSocketAddress::sizeOf |
( |
| ) |
|
|
inlinestatic |
Get size of object.
- Returns
- number of bytes
Definition at line 155 of file JSocketAddress.hh.
157 return sizeof(sockaddr_in);
The documentation for this class was generated from the following file: