NetBase::NetBase(int outqueuesize) : senders(outqueuesize) { randomgen = new csRandomGen; pipe_fd[0] = 0; pipe_fd[1] = 0; if (socklibrefcount==0 && initSocket()) ERRORHALT ("couldn't init socket library!"); socklibrefcount++; NetworkQueue.AttachNew(new NetPacketQueueRefCount(MAXQUEUESIZE)); if (!NetworkQueue) ERRORHALT("No Memory!"); ready=false; totaltransferout = 0; totaltransferin = 0; totalcountin = 0; totalcountout = 0; profs = new psNetMsgProfiles(); // Initialize the timeout to 30ms, adds 30ms of latency but gives time for packets to coalesce timeout.tv_sec = 0; timeout.tv_usec = 30000; accessPointers.msgstrings = NULL; accessPointers.msgstringshash = NULL; accessPointers.engine = NULL; logmsgfiltersetting.invert = false; logmsgfiltersetting.filterhex = true; logmsgfiltersetting.receive = false; logmsgfiltersetting.send = false; input_buffer = NULL; for(int i=0;i < NETAVGCOUNT;i++) { sendStats[i].senders = sendStats[i].messages = sendStats[i].time = 0; } for(int i =0;i < RESENDAVGCOUNT;i++) resends[i] = 0; avgIndex = resendIndex = 0; lastSendReport = csGetTicks(); }
bool Client::Initialize(LPSOCKADDR_IN addr, uint32_t clientnum) { Client::addr=*addr; CS_ASSERT_MSG("Unexpected size for IP address structure!", sizeof(addr->sin_addr.s_addr) + sizeof(addr->sin_port) == 6); Client::clientnum=clientnum; Client::valid=true; outqueue = csPtr<NetPacketQueueRefCount> (new NetPacketQueueRefCount (MAXCLIENTQUEUESIZE)); if (!outqueue) ERRORHALT("No Memory!"); return true; }