|
rllib
1
|
#include <rludpsocket.h>
Public Member Functions | |
| rlIpAdr () | |
| virtual | ~rlIpAdr () |
| int | setAdr (const char *adr, int port) |
| int | operator== (rlIpAdr &address1) |
Public Attributes | |
| struct sockaddr_in | address |
class for encapsulating ip addresses
Definition at line 40 of file rludpsocket.h.
| rlIpAdr::rlIpAdr | ( | ) |
Definition at line 21 of file rludpsocket.cpp.
| rlIpAdr::~rlIpAdr | ( | ) | [virtual] |
Definition at line 27 of file rludpsocket.cpp.
{
}
| int rlIpAdr::operator== | ( | rlIpAdr & | address1 | ) |
| int rlIpAdr::setAdr | ( | const char * | adr, |
| int | port | ||
| ) |
Definition at line 31 of file rludpsocket.cpp.
{
if(port < 0 || port >= 256*256) return -1;
struct in_addr IpAddress;
struct hostent *host;
memset(&IpAddress,0,sizeof(IpAddress));
memset(&address,0,sizeof(address));
host = gethostbyname(adr);
if(host == NULL)
{
// See if the host is specified in "dot address" form
IpAddress.s_addr = inet_addr(adr);
if(IpAddress.s_addr == INADDR_NONE)
{
::printf("rlIpAdr::setAdr() could not gethostbyname(%s)\n",adr);
return -1;
}
}
else
{
memcpy(&IpAddress,host->h_addr,host->h_length);
}
address.sin_family = AF_INET;
address.sin_port = htons((short) port);
address.sin_addr = IpAddress;
return 0;
}
| struct sockaddr_in rlIpAdr::address |
Definition at line 47 of file rludpsocket.h.
1.7.5.1