62 sin_addr.s_addr=INADDR_ANY;
72 sin_addr.s_addr=INADDR_ANY;
80 sin_port=addr.sin_port;
81 sin_addr.s_addr=addr.sin_addr.s_addr;
98 newAddr=inet_addr((
const char*)szIP);
102 HOSTENT* hostent=gethostbyname((
const char*)szIP);
104 memcpy(&newAddr,hostent->h_addr_list[0],hostent->h_length);
113 sin_addr.s_addr=newAddr;
114 sin_port=htons(port);
125 sin_port=htons(port);
134 return ntohs(sin_port);
151 HOSTENT* hosten=gethostbyaddr((
const char*)&sin_addr,4,AF_INET);
152 if(hosten==NULL||hosten->h_name==NULL)
154 else if(strlen(hosten->h_name)>=
len)
158 strcpy((
char*)buff,hosten->h_name);
171 memcpy(buff,&sin_addr.s_addr,4);
181 memcpy(&sin_addr.s_addr,ip,4);
197 char* strAddr=inet_ntoa(sin_addr);
200 if(strlen(strAddr)>=
len)
202 strcpy((
char*)buff,strAddr);
220 if(gethostname((
char*)buff,
len)==-1)
224 HOSTENT* hosten=gethostbyname((
char*)buff);
225 if(hosten==NULL||hosten->h_name==NULL)
227 else if(strlen(hosten->h_name)>=
len)
231 strcpy((
char*)buff,hosten->h_name);
249 if(gethostname(buff,256)==-1)
253 HOSTENT* hosten=gethostbyname((
char*)buff);
258 memcpy((
char*)ip,hosten->h_addr_list[0],4);
This class represents a socket address for Internet (IP) connections.
SINT32 setPort(UINT16 port)
Changes only(!) the port value of the address.
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.
SINT32 getIPAsStr(UINT8 *buff, UINT32 len) const
Returns the IP-Number as an address string (doted-format).
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.