checkpoint. merging win32 code. server on X is currently broken

and client probably is.
This commit is contained in:
crs
2001-11-19 00:33:36 +00:00
parent 51505783aa
commit 3f6146b15f
66 changed files with 5222 additions and 424 deletions

View File

@@ -1,8 +1,4 @@
#include "CNetworkAddress.h"
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
//
// CNetworkAddress
@@ -15,7 +11,7 @@ CNetworkAddress::CNetworkAddress(UInt16 port)
struct sockaddr_in* inetAddress = reinterpret_cast<struct sockaddr_in*>(&m_address);
inetAddress->sin_family = AF_INET;
inetAddress->sin_port = htons(port);
inetAddress->sin_port = CNetwork::swaphtons(port);
inetAddress->sin_addr.s_addr = INADDR_ANY;
memset(inetAddress->sin_zero, 0, sizeof(inetAddress->sin_zero));
}
@@ -25,17 +21,17 @@ CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
if (port == 0)
throw XSocketAddress(XSocketAddress::kBadPort, hostname, port);
struct hostent* hent = gethostbyname(hostname.c_str());
struct hostent* hent = CNetwork::gethostbyname(hostname.c_str());
if (hent == NULL) {
switch (h_errno) {
case HOST_NOT_FOUND:
switch (CNetwork::gethosterror()) {
case CNetwork::kHOST_NOT_FOUND:
throw XSocketAddress(XSocketAddress::kNotFound, hostname, port);
case NO_DATA:
case CNetwork::kNO_DATA:
throw XSocketAddress(XSocketAddress::kNoAddress, hostname, port);
case NO_RECOVERY:
case TRY_AGAIN:
case CNetwork::kNO_RECOVERY:
case CNetwork::kTRY_AGAIN:
default:
throw XSocketAddress(XSocketAddress::kUnknown, hostname, port);
}
@@ -43,7 +39,7 @@ CNetworkAddress::CNetworkAddress(const CString& hostname, UInt16 port)
struct sockaddr_in* inetAddress = reinterpret_cast<struct sockaddr_in*>(&m_address);
inetAddress->sin_family = hent->h_addrtype;
inetAddress->sin_port = htons(port);
inetAddress->sin_port = CNetwork::swaphtons(port);
memcpy(&inetAddress->sin_addr, hent->h_addr_list[0], hent->h_length);
memset(inetAddress->sin_zero, 0, sizeof(inetAddress->sin_zero));
}
@@ -53,12 +49,12 @@ CNetworkAddress::~CNetworkAddress()
// do nothing
}
const struct sockaddr* CNetworkAddress::getAddress() const
const CNetwork::Address* CNetworkAddress::getAddress() const
{
return &m_address;
}
int CNetworkAddress::getAddressLength() const
CNetwork::AddressLength CNetworkAddress::getAddressLength() const
{
return sizeof(m_address);
}