Game Development Reference
In-Depth Information
bool Init();
void Shutdown();
int AddSocket(NetSocket *socket);
void RemoveSocket(NetSocket *socket);
bool Send(int sockId, shared_ptr<IPacket> packet);
void DoSelect(int pauseMicroSecs, int handleInput = 1);
void SetSubnet(unsigned int subnet, unsigned int subnetMask)
{
m_Subnet = subnet;
m_SubnetMask = subnetMask;
}
bool IsInternal(unsigned int ipaddr);
unsigned int GetHostByName(std::string hostName);
const char *GetHostByAddr(unsigned int ip);
void AddToOutbound(int rc) { m_Outbound += rc; }
void AddToInbound(int rc) { m_Inbound += rc; }
protected:
WSADATA m_WsaData;
// describes sockets system implementation
typedef std::list<NetSocket *> SocketList;
typedef std::map<int, NetSocket *> SocketIdMap;
SocketList m_SockList;
// a list of sockets
SocketIdMap m_SockMap;
// a map from integer IDs to socket handles
int m_NextSocketId;
// a ticker for the next socket ID
unsigned int m_Inbound; // statistics gathering - inbound data
unsigned int m_Outbound; // statistics gathering - outbound data
unsigned int m_MaxOpenSockets; // statistics gathering - max open sockets
unsigned int m_SubnetMask; // the subnet mask of the internal network
unsigned int m_Subnet;
// the subnet of the internal network
NetSocket *FindSocket(int sockId);
};
One of the core features of the socket manager is the notion that each socket has a
companion identifier. In this implementation of the manager, a counter is used to
guarantee a unique ID for each socket in the system. This is different than a handle
because this ID could be something much more significant, such as a player ID
Search WWH ::




Custom Search