mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-10-17 07:03:02 -04:00
this is a more "clean" conversion to 64 bit than the type-fixups branch, which does borrow some elements from it but has far less find and replace...it is about 98-99% done, notes to follow later
This commit is contained in:
@@ -21,7 +21,7 @@ hostAddress("0.0.0.0")
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
Address::Address(const std::string & newHostAddress, unsigned short newHostPort) :
|
||||
Address::Address(const std::string & newHostAddress, uint16_t newHostPort) :
|
||||
addr4(new struct sockaddr_in),
|
||||
hostAddress(newHostAddress)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ const std::string & Address::getHostAddress() const
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
const unsigned short Address::getHostPort() const
|
||||
const uint16_t Address::getHostPort() const
|
||||
{
|
||||
return ntohs(addr4->sin_port);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ m_rawTCP( false )
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TcpClient::TcpClient (const std::string & a, const unsigned short port) :
|
||||
TcpClient::TcpClient (const std::string & a, const uint16_t port) :
|
||||
m_socket(-1),
|
||||
m_tcpServer(0),
|
||||
m_connection(0),
|
||||
@@ -124,7 +124,7 @@ std::string const &TcpClient::getRemoteAddress() const
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
unsigned short TcpClient::getRemotePort() const
|
||||
uint16_t TcpClient::getRemotePort() const
|
||||
{
|
||||
return m_remoteAddress.getHostPort();
|
||||
}
|
||||
@@ -268,7 +268,7 @@ void TcpClient::flushPendingWrites()
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
unsigned short TcpClient::getBindPort() const
|
||||
uint16_t TcpClient::getBindPort() const
|
||||
{
|
||||
return m_bindPort;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class TcpClient
|
||||
{
|
||||
public:
|
||||
TcpClient(int sock, TcpServer *);
|
||||
TcpClient(const std::string & address, const unsigned short port);
|
||||
TcpClient(const std::string & address, const uint16_t port);
|
||||
|
||||
void addRef();
|
||||
static void install();
|
||||
@@ -30,9 +30,9 @@ public:
|
||||
static void remove();
|
||||
void send(const unsigned char * const buffer, const int length);
|
||||
|
||||
unsigned short getBindPort() const;
|
||||
uint16_t getBindPort() const;
|
||||
std::string const &getRemoteAddress() const;
|
||||
unsigned short getRemotePort() const;
|
||||
uint16_t getRemotePort() const;
|
||||
void setPendingSendAllocatedSizeLimit(unsigned int limit);
|
||||
|
||||
// only used by clients
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
int m_refCount;
|
||||
bool m_connected;
|
||||
unsigned long m_lastSendTime;
|
||||
unsigned short m_bindPort;
|
||||
uint16_t m_bindPort;
|
||||
bool m_rawTCP;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
TcpServer::TcpServer(Service * service, const std::string & a, const unsigned short port) :
|
||||
TcpServer::TcpServer(Service * service, const std::string & a, const uint16_t port) :
|
||||
m_bindAddress(a, port),
|
||||
m_handle(-1),
|
||||
m_service(service),
|
||||
@@ -78,7 +78,7 @@ const std::string & TcpServer::getBindAddress() const
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
const unsigned short TcpServer::getBindPort() const
|
||||
const uint16_t TcpServer::getBindPort() const
|
||||
{
|
||||
return m_bindAddress.getHostPort();
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ class TcpClient;
|
||||
class TcpServer
|
||||
{
|
||||
public:
|
||||
TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort);
|
||||
TcpServer(Service * service, const std::string & bindAddress, const uint16_t bindPort);
|
||||
~TcpServer();
|
||||
|
||||
const std::string & getBindAddress () const;
|
||||
const unsigned short getBindPort () const;
|
||||
const uint16_t getBindPort () const;
|
||||
void onConnectionClosed (TcpClient *);
|
||||
void removeClient (TcpClient *);
|
||||
void update ();
|
||||
|
||||
@@ -25,7 +25,7 @@ class Address
|
||||
{
|
||||
public:
|
||||
Address();
|
||||
Address(const std::string & dottedDecimalIPv4Address, unsigned short hostPort);
|
||||
Address(const std::string & dottedDecimalIPv4Address, uint16_t hostPort);
|
||||
Address(const Address & source);
|
||||
Address(const struct sockaddr_in & ipv4sockaddr);
|
||||
~Address();
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
const bool operator!=(const Address & rhs) const;
|
||||
const bool operator>(const Address & rhs) const;
|
||||
const std::string & getHostAddress() const;
|
||||
const unsigned short getHostPort() const;
|
||||
const uint16_t getHostPort() const;
|
||||
size_t hashFunction() const;
|
||||
const struct sockaddr_in & getSockAddr4() const;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ udp(new UdpSock)
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const bool BroadcastSock::bind(const unsigned short port)
|
||||
const bool BroadcastSock::bind(const uint16_t port)
|
||||
{
|
||||
return udp->bind(Address("", port));
|
||||
}
|
||||
@@ -54,7 +54,7 @@ const unsigned int BroadcastSock::recvFrom(Address & a, void * targetBuffer, con
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const unsigned int BroadcastSock::sendTo(const std::string & a, const unsigned short p, const void * b, const unsigned int l) const
|
||||
const unsigned int BroadcastSock::sendTo(const std::string & a, const uint16_t p, const void * b, const unsigned int l) const
|
||||
{
|
||||
return udp->sendTo(Address(a, p), b, l);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ class BroadcastSock
|
||||
public:
|
||||
BroadcastSock();
|
||||
virtual ~BroadcastSock();
|
||||
const bool bind(const unsigned short port);
|
||||
const unsigned int sendTo(const std::string & address, const unsigned short port, const void * sourceBuffer, const unsigned int sourceBufferLength) const;
|
||||
const bool bind(const uint16_t port);
|
||||
const unsigned int sendTo(const std::string & address, const uint16_t port, const void * sourceBuffer, const unsigned int sourceBufferLength) const;
|
||||
const bool canRecv() const;
|
||||
const unsigned int recvFrom(Address & outAddress, void * targetBuffer, const unsigned int targetBufferSize) const;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace ConfigSharedNetworkNamespace
|
||||
bool logConnectionOpenedClosed;
|
||||
int logConnectionDeferredMessagesWarningInterval;
|
||||
|
||||
typedef unsigned short ReservedPortInt;
|
||||
typedef uint16_t ReservedPortInt;
|
||||
typedef std::set<ReservedPortInt> ReservedPortSet;
|
||||
ReservedPortSet reservedPorts;
|
||||
|
||||
@@ -473,7 +473,7 @@ int ConfigSharedNetwork::getMaxTCPRetries()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool ConfigSharedNetwork::getIsPortReserved(unsigned short p)
|
||||
bool ConfigSharedNetwork::getIsPortReserved(uint16_t p)
|
||||
{
|
||||
ReservedPortSet::const_iterator f = reservedPorts.find(p);
|
||||
return (f != reservedPorts.end());
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
static bool getLogConnectionOpenedClosed();
|
||||
static bool getLogConnectionDeferredMessagesWarning();
|
||||
static int getLogConnectionDeferredMessagesWarningInterval();
|
||||
static bool getIsPortReserved(unsigned short p);
|
||||
static bool getIsPortReserved(uint16_t p);
|
||||
static bool getNetworkHandlerDispatchThrottle();
|
||||
static int getNetworkHandlerDispatchThrottleTimeMilliseconds();
|
||||
static int getNetworkHandlerDispatchQueueSize();
|
||||
|
||||
@@ -159,7 +159,7 @@ const int DeferredSendLogicalPacket::getSize() const
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Connection::Connection(const std::string & a, const unsigned short p, const NetworkSetupData & setup) :
|
||||
Connection::Connection(const std::string & a, const uint16_t p, const NetworkSetupData & setup) :
|
||||
udpConnection(0),
|
||||
m_pendingPackets(),
|
||||
m_currentFrame(0),
|
||||
@@ -234,7 +234,7 @@ m_disconnectReason()
|
||||
{
|
||||
UdpManagerMT *m = new UdpManagerMT(&p);
|
||||
m_udpManager = m;
|
||||
setBindPort(static_cast<unsigned short>(m_udpManager->GetLocalPort()));
|
||||
setBindPort(static_cast<uint16_t>(m_udpManager->GetLocalPort()));
|
||||
if (isPortReserved(getBindPort()))
|
||||
{
|
||||
m_udpManager->Release();
|
||||
@@ -321,7 +321,7 @@ m_disconnectReason()
|
||||
char addrBuf[1024] = {"\0"};
|
||||
newConnection->GetDestinationIp().GetAddress(addrBuf);
|
||||
m_remoteAddress = addrBuf;
|
||||
m_remotePort = static_cast<unsigned short>(newConnection->GetDestinationPort());
|
||||
m_remotePort = static_cast<uint16_t>(newConnection->GetDestinationPort());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -522,7 +522,7 @@ const std::string & Connection::getRemoteAddress() const
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const unsigned short Connection::getRemotePort() const
|
||||
const uint16_t Connection::getRemotePort() const
|
||||
{
|
||||
return m_remotePort;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UdpConnectionMT;
|
||||
class Connection : public NetworkHandler
|
||||
{
|
||||
public:
|
||||
Connection (const std::string & remoteAddress, const unsigned short remotePort, const NetworkSetupData & setup);
|
||||
Connection (const std::string & remoteAddress, const uint16_t remotePort, const NetworkSetupData & setup);
|
||||
explicit Connection (UdpConnectionMT * newConnection, TcpClient * t = 0);
|
||||
|
||||
virtual ~Connection ();
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
void describeConnection (const std::string &);
|
||||
const std::string & getConnectionDescription () const;
|
||||
const std::string & getRemoteAddress () const;
|
||||
const unsigned short getRemotePort () const;
|
||||
const uint16_t getRemotePort () const;
|
||||
const UdpConnectionMT * getUdpConnection () const;
|
||||
UdpConnectionMT * getUdpConnection ();
|
||||
WatchedByList &getWatchedByList () const;
|
||||
@@ -105,7 +105,7 @@ protected:
|
||||
|
||||
private:
|
||||
std::string m_remoteAddress;
|
||||
unsigned short m_remotePort;
|
||||
uint16_t m_remotePort;
|
||||
std::vector<DeferredSend *> m_deferredMessages;
|
||||
int m_deferredDataSize;
|
||||
mutable WatchedByList m_watchedByList;
|
||||
|
||||
@@ -208,7 +208,7 @@ const std::string & NetworkHandler::getBindAddress() const
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const unsigned short NetworkHandler::getBindPort() const
|
||||
const uint16_t NetworkHandler::getBindPort() const
|
||||
{
|
||||
return m_bindPort;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ void NetworkHandler::setBindAddress(const std::string & address)
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void NetworkHandler::setBindPort(const unsigned short p)
|
||||
void NetworkHandler::setBindPort(const uint16_t p)
|
||||
{
|
||||
m_bindPort = p;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ bool NetworkHandler::removing()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool NetworkHandler::isPortReserved(unsigned short p)
|
||||
bool NetworkHandler::isPortReserved(uint16_t p)
|
||||
{
|
||||
return(ConfigSharedNetwork::getIsPortReserved(p));
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ public:
|
||||
|
||||
virtual void onConnectionOpened (UdpConnectionMT *) = 0;
|
||||
const std::string & getBindAddress () const;
|
||||
const unsigned short getBindPort () const;
|
||||
const uint16_t getBindPort () const;
|
||||
virtual void onConnectionClosed (Connection *) = 0;
|
||||
void setBindAddress (const std::string & address);
|
||||
void setBindPort (const unsigned short port);
|
||||
void setBindPort (const uint16_t port);
|
||||
static bool removing ();
|
||||
LogicalPacket const * createPacket (unsigned char const *data, int size);
|
||||
void releasePacket (LogicalPacket const *p);
|
||||
static bool isPortReserved (unsigned short port);
|
||||
static bool isPortReserved (uint16_t port);
|
||||
static void onTerminate (Connection * c);
|
||||
|
||||
protected:
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
NetworkHandler(const NetworkHandler & source);
|
||||
|
||||
private:
|
||||
unsigned short m_bindPort;
|
||||
uint16_t m_bindPort;
|
||||
std::string m_bindAddress;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
int reliableOverflowBytes;
|
||||
int icmpErrorRetryPeriod;
|
||||
int maxDataHoldSize;
|
||||
unsigned short port;
|
||||
uint16_t port;
|
||||
std::string bindInterface;
|
||||
bool compress;
|
||||
bool allowPortRemapping;
|
||||
|
||||
@@ -23,7 +23,7 @@ ConnectionAllocatorBase::~ConnectionAllocatorBase()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
//Service::Service(const ConnectionAllocatorBase & c, const unsigned short port, const int m, const int keepAliveDelay, const std::string & interfaceAddress, const bool compress) :
|
||||
//Service::Service(const ConnectionAllocatorBase & c, const uint16_t port, const int m, const int keepAliveDelay, const std::string & interfaceAddress, const bool compress) :
|
||||
Service::Service(const ConnectionAllocatorBase & c, const NetworkSetupData & setup) :
|
||||
connectionAllocator(c.clone()),
|
||||
m_callback(new MessageDispatch::Callback),
|
||||
@@ -130,7 +130,7 @@ m_tcpServer(0)
|
||||
}
|
||||
|
||||
m_udpManager = m;
|
||||
setBindPort(static_cast<unsigned short>(m_udpManager->GetLocalPort()));
|
||||
setBindPort(static_cast<uint16_t>(m_udpManager->GetLocalPort()));
|
||||
if(isPortReserved(getBindPort()))
|
||||
{
|
||||
m = new UdpManagerMT(&p);
|
||||
@@ -142,7 +142,7 @@ m_tcpServer(0)
|
||||
else
|
||||
{
|
||||
m_udpManager = new UdpManagerMT(&p);
|
||||
setBindPort(static_cast<unsigned short>(m_udpManager->GetLocalPort()));
|
||||
setBindPort(static_cast<uint16_t>(m_udpManager->GetLocalPort()));
|
||||
}
|
||||
|
||||
newManager(m_udpManager);
|
||||
|
||||
@@ -58,7 +58,7 @@ struct ConnectionAllocator : public ConnectionAllocatorBase
|
||||
class Service : public NetworkHandler
|
||||
{
|
||||
public:
|
||||
//Service(const ConnectionAllocatorBase & connectionAllocator, const unsigned short listenPort, const int maxConnections, const int keepAliveDelay = 1000, const std::string & interfaceAddress = std::string(""), const bool compress=false);
|
||||
//Service(const ConnectionAllocatorBase & connectionAllocator, const uint16_t listenPort, const int maxConnections, const int keepAliveDelay = 1000, const std::string & interfaceAddress = std::string(""), const bool compress=false);
|
||||
Service(const ConnectionAllocatorBase & connectionAllocator, const NetworkSetupData & setupData);
|
||||
virtual ~Service();
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ int UdpConnectionMT::TotalPendingBytes() const
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
unsigned short UdpConnectionMT::ServerSyncStampShort() const
|
||||
uint16_t UdpConnectionMT::ServerSyncStampShort() const
|
||||
{
|
||||
// TODO: is there a cleaner way to deal with this?
|
||||
Guard lock(UdpLibraryMT::getMutex());
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
void *GetPassThroughData() const;
|
||||
UdpConnection::Status GetStatus() const;
|
||||
int TotalPendingBytes() const;
|
||||
unsigned short ServerSyncStampShort() const;
|
||||
uint16_t ServerSyncStampShort() const;
|
||||
unsigned long ServerSyncStampLong() const;
|
||||
UdpIpAddress GetDestinationIp() const;
|
||||
int GetDestinationPort() const;
|
||||
|
||||
@@ -37,7 +37,7 @@ hostAddress("0.0.0.0")
|
||||
@todo Add a static resolver cache to Address to reduce potential
|
||||
calls to gethostbyname()
|
||||
*/
|
||||
Address::Address(const std::string & newHostAddress, const unsigned short newHostPort) :
|
||||
Address::Address(const std::string & newHostAddress, const uint16_t newHostPort) :
|
||||
addr4(new struct sockaddr_in),
|
||||
hostAddress(newHostAddress)
|
||||
{
|
||||
@@ -220,7 +220,7 @@ const std::string & Address::getHostAddress() const
|
||||
|
||||
@author Justin Randall
|
||||
*/
|
||||
const unsigned short Address::getHostPort() const
|
||||
const uint16_t Address::getHostPort() const
|
||||
{
|
||||
return ntohs(addr4->sin_port);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ m_rawTCP( false )
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TcpClient::TcpClient(const std::string & remoteAddress, const unsigned short remotePort) :
|
||||
TcpClient::TcpClient(const std::string & remoteAddress, const uint16_t remotePort) :
|
||||
m_connectEvent(INVALID_HANDLE_VALUE),
|
||||
m_socket(),
|
||||
m_localIOCP(INVALID_HANDLE_VALUE),
|
||||
@@ -146,7 +146,7 @@ void TcpClient::addRef()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
unsigned short TcpClient::getBindPort() const
|
||||
uint16_t TcpClient::getBindPort() const
|
||||
{
|
||||
return m_bindPort;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ std::string const &TcpClient::getRemoteAddress() const
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
unsigned short TcpClient::getRemotePort() const
|
||||
uint16_t TcpClient::getRemotePort() const
|
||||
{
|
||||
// TODO: implement this
|
||||
return 0;
|
||||
|
||||
@@ -21,15 +21,15 @@ class TcpClient
|
||||
{
|
||||
public:
|
||||
explicit TcpClient(HANDLE parentIOCP);
|
||||
TcpClient(const std::string & address, const unsigned short port);
|
||||
TcpClient(const std::string & address, const uint16_t port);
|
||||
~TcpClient();
|
||||
|
||||
static void install();
|
||||
static void remove();
|
||||
void send(const unsigned char * const buffer, const int length);
|
||||
unsigned short getBindPort() const;
|
||||
uint16_t getBindPort() const;
|
||||
std::string const &getRemoteAddress() const;
|
||||
unsigned short getRemotePort() const;
|
||||
uint16_t getRemotePort() const;
|
||||
void setPendingSendAllocatedSizeLimit(unsigned int limit);
|
||||
|
||||
// only used by clients
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
bool m_connected;
|
||||
bool m_ownHandle;
|
||||
unsigned long m_lastSendTime;
|
||||
unsigned short m_bindPort;
|
||||
uint16_t m_bindPort;
|
||||
|
||||
bool m_rawTCP;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
TcpServer::TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort) :
|
||||
TcpServer::TcpServer(Service * service, const std::string & bindAddress, const uint16_t bindPort) :
|
||||
m_handle(),
|
||||
m_localIOCP(),
|
||||
m_pendingConnections(),
|
||||
@@ -70,7 +70,7 @@ TcpClient * TcpServer::accept()
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
const unsigned short TcpServer::getBindPort() const
|
||||
const uint16_t TcpServer::getBindPort() const
|
||||
{
|
||||
return m_bindPort;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ class TcpClient;
|
||||
class TcpServer
|
||||
{
|
||||
public:
|
||||
TcpServer(Service * service, const std::string & bindAddress, const unsigned short bindPort);
|
||||
TcpServer(Service * service, const std::string & bindAddress, const uint16_t bindPort);
|
||||
~TcpServer();
|
||||
|
||||
TcpClient * accept ();
|
||||
const std::string & getBindAddress () const;
|
||||
const unsigned short getBindPort () const;
|
||||
const uint16_t getBindPort () const;
|
||||
void onConnectionClosed (TcpClient *);
|
||||
void update ();
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
HANDLE m_localIOCP;
|
||||
std::vector<TcpClient *> m_pendingConnections;
|
||||
std::string m_bindAddress;
|
||||
unsigned short m_bindPort;
|
||||
uint16_t m_bindPort;
|
||||
Service * m_service;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user