28 #ifndef __CASOCKETADDRINET__
29 #define __CASOCKETADDRINET__
67 #if defined(_WIN32) &&!defined(MSC_VER)
79 return sizeof(sockaddr_in);
91 return sin_addr.s_addr==INADDR_ANY;
96 return (memcmp(ip,&sin_addr.s_addr,4)==0);
106 SINT32 ret = inet_pton(AF_INET,(
const char*)strIP,&addr);
111 UINT32 uAddr = ntohl(addr.s_addr);
112 ip[0] = (uAddr >> 24) & 0xFF;
113 ip[1] = (uAddr >> 16) & 0xFF;
114 ip[2] = (uAddr >> 8) & 0xFF;
115 ip[3] = (uAddr) & 0xFF;
133 if(snprintf((
char*)buff,bufflen,
"INet address: %s:%u",tmpbuff,
getPort())<0)
This is an abstract class for representing a socket address used in CASocket, CADatagramSocket and CA...
This class represents a socket address for Internet (IP) connections.
SINT32 setPort(UINT16 port)
Changes only(!) the port value of the address.
CASocketAddr * clone() const
Creates a copy of the Address.
bool equalsIP(UINT8 ip[4]) const
SINT32 getType() const
The type (family) of socket for which this address is useful.
static CAMutex * m_pcsGet
SINT32 setAddr(const UINT8 *szIP, UINT16 port)
Sets the address to szIP and port.
SINT32 setIP(UINT8 ip[4])
Sets the IP-Numbers for this address.
SINT32 getHostName(UINT8 *buff, UINT32 len) const
Returns the hostname for this address.
CASocketAddrINet()
Must be called once before using one of the CAsocketAddrINet functions.
const SOCKADDR * LPSOCKADDR() const
Makes a cast to struct SOCKADDR*.
SINT32 getSize() const
Returns the Size of the SOCKADDR struct used.
static SINT32 getIPForString(UINT8 *strIP, UINT8 ip[4])
SINT32 getIPAsStr(UINT8 *buff, UINT32 len) const
Returns the IP-Number as an address string (doted-format).
virtual SINT32 toString(UINT8 *buff, UINT32 bufflen) const
Returns a human readable representation of this address.
static SINT32 getLocalHostName(UINT8 *buff, UINT32 len)
Returns the name of the local host.
static SINT32 getLocalHostIP(UINT8 ip[4])
Returns the local IP-Address as four bytes.
UINT16 getPort() const
Returns the port value of the address.
SINT32 getIP(UINT8 buff[4]) const
Returns the IP-Numbers for this address.