OpenClonk
C4Network2IO.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 #ifndef INC_C4Network2IO
17 #define INC_C4Network2IO
18 
20 #include "network/C4Client.h"
22 #include "network/C4NetIO.h"
23 
24 #include <atomic>
25 
27 
28 // enums & constants
30 {
32 };
33 
34 const int C4NetTimer = 500, // ms
35  C4NetPingFreq = 1000, // ms
36  C4NetStatisticsFreq = 1000, // ms
37  C4NetAcceptTimeout = 10, // s
38  C4NetPingTimeout = 30000;// ms
39 
40 // client count
41 const int C4NetMaxClients = 256;
42 
45  protected C4NetIO::CBClass,
46  protected StdSchedulerProc
47 {
48 public:
49  C4Network2IO();
50  ~C4Network2IO() override;
51 
52 protected:
53 
54  // main traffic net i/o classes
55  C4NetIO *pNetIO_TCP{nullptr}, *pNetIO_UDP{nullptr};
56 
57  // discovery net i/o
59 
60  // reference server
62 
63  // UPnP port mapping manager
64  class C4Network2UPnP *UPnPMgr{nullptr};
65 
66  // local client core
69 
70  // connection list
73 
74  // next connection ID to use
75  uint32_t iNextConnID{0};
76 
77  // allow incoming connections?
78  bool fAllowConnect{false};
79 
80  // connection acceptance
81  struct AutoAccept
82  {
85  }
86  *pAutoAcceptList{nullptr};
88 
89  // make sure only one connection is established?
90  bool fExclusiveConn{false};
91 
92  // timer & ping
95 
96  // statistics
98  int iTCPIRate{0}, iTCPORate{0}, iTCPBCRate{0},
100 
101  // punching
103  bool IsPuncherAddr(const C4NetIO::addr_t& addr) const;
104 
105 public:
106 
107  bool hasTCP() const { return !! pNetIO_TCP; }
108  bool hasUDP() const { return !! pNetIO_UDP; }
109 
110  // initialization
111  bool Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscovery = -1, int16_t iPortRefServer = -1, bool fBroadcast = false, bool enable_upnp = true); // by main thread
112  void Clear(); // by main thread
113  void SetLocalCCore(const C4ClientCore &CCore); // by main thread
114 
115  // i/o types
116  C4NetIO *MsgIO(); // by both
117  C4NetIO *DataIO(); // by both
118 
119  // connections
120  bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword = nullptr); // by main thread
121  bool ConnectWithSocket(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, std::unique_ptr<C4NetIOTCP::Socket> socket, const char *szPassword = nullptr); // by main thread
122  void SetAcceptMode(bool fAcceptAll); // by main thread
123  void SetExclusiveConnMode(bool fExclusiveConn); // by main thread
124  int getConnectionCount(); // by main thread
125 
126  void ClearAutoAccept(); // by main thread
127  void AddAutoAccept(const C4ClientCore &CCore); // by main thread
128  void RemoveAutoAccept(const C4ClientCore &CCore); // by main thread
129 
130  C4Network2IOConnection *GetMsgConnection(int iClientID); // by both (returns referenced connection!)
131  C4Network2IOConnection *GetDataConnection(int iClientID); // by both (returns referenced connection!)
132 
133  // broadcasting
134  void BeginBroadcast(bool fSelectAll = false); // by both
135  void EndBroadcast(); // by both
136  bool Broadcast(const C4NetIOPacket &rPkt); // by both
137 
138  // sending helpers
139  bool SendMsgToClient(C4NetIOPacket &rPkt, int iClient); // by both
140  bool BroadcastMsg(const C4NetIOPacket &rPkt); // by both
141 
142  // punch
143  bool InitPuncher(C4NetIO::addr_t PuncherAddr); // by main thread
145  void Punch(const C4NetIO::addr_t&); // sends a ping packet
146 
147  // stuff
148  C4NetIO *getNetIO(C4Network2IOProtocol eProt); // by both
149  const char *getNetIOName(C4NetIO *pNetIO);
151 
152  // statistics
153  int getProtIRate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPIRate : iUDPIRate; }
154  int getProtORate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPORate : iUDPORate; }
155  int getProtBCRate(C4Network2IOProtocol eProt) const { return eProt == P_TCP ? iTCPBCRate : iUDPBCRate; }
156 
157  // reference
158  void SetReference(class C4Network2Reference *pReference);
159  bool IsReferenceNeeded();
160 
161 protected:
162  // *** callbacks
163  // C4NetIO-Callbacks
164  bool OnConn(const C4NetIO::addr_t &addr, const C4NetIO::addr_t &AddrConnect, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO) override;
165  void OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason) override;
166  void OnPacket(const C4NetIOPacket &rPacket, C4NetIO *pNetIO) override;
167  // C4NetIOMan
168  virtual void OnError(const char *strError, C4NetIO *pNetIO);
169  // StdSchedulerProc
170  bool Execute(int iTimeout, pollfd *) override;
172  // Event callback by C4InteractiveThread
173  void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) override; // by main thread
174 
175  // connections list
176  void AddConnection(C4Network2IOConnection *pConn); // by both
177  void RemoveConnection(C4Network2IOConnection *pConn); // by both
178  C4Network2IOConnection *GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO); // by both
179  C4Network2IOConnection *GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO); // by both
180  C4Network2IOConnection *GetConnectionByID(uint32_t iConnID); // by thread
181 
182  // network events (signals to main thread)
183  struct NetEvPacketData;
184 
185  // connection acceptance
186  bool doAutoAccept(const C4ClientCore &CCore, const C4Network2IOConnection &Conn);
187 
188  // general packet handling (= forward in most cases)
189  bool HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread); // by both
190  void CallHandlers(int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread); // by both
191 
192  // packet handling (some are really handled here)
193  void HandlePacket(char cStatus, const C4PacketBase *pPacket, C4Network2IOConnection *pConn);
194  void HandleFwdReq(const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy);
195  void HandlePuncherPacket(const C4NetIOPacket &rPacket);
196 
197  // misc
198  bool Ping();
199  void CheckTimeout();
200  void GenerateStatistics(int iInterval);
201  void SendConnPackets();
202 };
203 
205 {
206  CS_Connect, // waiting for connection
207  CS_Connected, // waiting for Conn
208  CS_HalfAccepted, // got Conn (peer identified, client class created if neccessary)
209  CS_Accepted, // got ConnRe (peer did accept)
211  CS_ConnectFail // got closed before HalfAccepted was reached
212 };
213 
214 class C4Network2IOConnection // shared
215 {
216  friend class C4Network2IO;
217 public:
220 
221 protected:
222 
223  // connection data
224  class C4NetIO *pNetClass{nullptr};
226  C4NetIO::addr_t PeerAddr, ConnectAddr;
227  std::unique_ptr<C4NetIOTCP::Socket> TcpSimOpenSocket;
228 
229  // status data
231  uint32_t iID, iRemoteID; // connection ID for this and the remote client
232  bool fAutoAccept{false}; // auto accepted by thread?
233  bool fBroadcastTarget{false}; // broadcast target?
234  time_t iTimestamp{0}; // timestamp of last status change
235  int iPingTime{-1}; // ping
236  C4TimeMilliseconds tLastPing; // if > iLastPong, it's the first ping that hasn't been answered yet, nullptr if no ping received yet
237  C4TimeMilliseconds tLastPong; // last pong received, nullptr if no pong received yet
238  C4ClientCore CCore; // client core (>= CS_HalfAccepted)
240  int iIRate, iORate; // input/output rates (by C4NetIO, in b/s)
241  int iPacketLoss; // lost packets (in the last seconds)
242  StdCopyStrBuf Password; // password to use for connect
243  bool fConnSent{false}; // initial connection packet send
244  bool fPostMortemSent{false}; // post mortem send
245 
246  // packet backlog
247  uint32_t iOutPacketCounter{0}, iInPacketCounter{0};
249  {
250  uint32_t Number;
253  };
254  PacketLogEntry *pPacketLog{nullptr};
256 
257  // list (C4Network2IO)
258  C4Network2IOConnection *pNext{nullptr};
259 
260  // reference counter
261  std::atomic_long iRefCnt;
262 
263 public:
264  C4NetIO *getNetClass() const { return pNetClass; }
265  C4Network2IOProtocol getProtocol() const { return eProt; }
266  const C4NetIO::addr_t &getPeerAddr() const { return PeerAddr.GetPort() ? PeerAddr : ConnectAddr; }
267  const C4NetIO::addr_t &getConnectAddr() const { return ConnectAddr; }
268  uint32_t getID() const { return iID; }
269  uint32_t getRemoteID() const { return iRemoteID; }
270  time_t getTimestamp() const { return iTimestamp; }
271  const C4ClientCore &getCCore() const { return CCore; }
272  CStdCSec &getCCoreCSec() { return CCoreCSec; }
273  int getClientID() const { return CCore.getID(); }
274  bool isHost() const { return CCore.isHost(); }
275  int getPingTime() const { return iPingTime; }
276  int getLag() const;
277  int getIRate() const { return iIRate; }
278  int getORate() const { return iORate; }
279  int getPacketLoss() const { return iPacketLoss; }
280  const char *getPassword() const { return Password.getData(); }
281  bool isConnSent() const { return fConnSent; }
282 
283  uint32_t getInPacketCounter() const { return iInPacketCounter; }
284  uint32_t getOutPacketCounter() const { return iOutPacketCounter; }
285 
286  bool isConnecting() const { return Status == CS_Connect; }
287  bool isOpen() const { return Status != CS_Connect && Status != CS_Closed && Status != CS_ConnectFail; }
288  bool isHalfAccepted()const { return Status == CS_HalfAccepted || Status == CS_Accepted; }
289  bool isAccepted() const { return Status == CS_Accepted; }
290  bool isClosed() const { return Status == CS_Closed || Status == CS_ConnectFail; }
291  bool isAutoAccepted()const { return fAutoAccept; }
292  bool isBroadcastTarget() const { return fBroadcastTarget; }
293  bool isFailed() const { return Status == CS_ConnectFail; }
294 
295 protected:
296  // called by C4Network2IO only
297  void Set(C4NetIO *pnNetClass, C4Network2IOProtocol eProt, const C4NetIO::addr_t &nPeerAddr, const C4NetIO::addr_t &nConnectAddr, C4Network2IOConnStatus nStatus, const char *szPassword, uint32_t iID);
298  void SetSocket(std::unique_ptr<C4NetIOTCP::Socket> socket);
299  void SetRemoteID(uint32_t iRemoteID);
300  void SetPeerAddr(const C4NetIO::addr_t &nPeerAddr);
301  void OnPing();
302  void SetPingTime(int iPingTime);
303  void SetStatus(C4Network2IOConnStatus nStatus);
304  void SetAutoAccepted();
305  void OnPacketReceived(uint8_t iPacketType);
306  void ClearPacketLog(uint32_t iStartNumber = ~0);
307 
308 public:
309  // status changing
310  void SetHalfAccepted() { SetStatus(CS_HalfAccepted); }
311  void SetAccepted() { SetStatus(CS_Accepted); }
312  void SetCCore(const C4ClientCore &nCCore);
313  void ResetAutoAccepted() { fAutoAccept = false; }
314  void SetConnSent() { fConnSent = true; }
315 
316  // connection operations
317  bool Connect();
318  void Close();
319  bool Send(const C4NetIOPacket &rPkt);
320  void SetBroadcastTarget(bool fSet); // (only call after C4Network2IO::BeginBroadcast!)
321 
322  // statistics
323  void DoStatistics(int iInterval, int *pIRateSum, int *pORateSum);
324 
325  // reference counting
326  void AddRef(); void DelRef();
327 
328  // post mortem
329  bool CreatePostMortem(class C4PacketPostMortem *pPkt);
330 
331 };
332 
333 // * Packets *
334 
336 {
337 public:
338  C4PacketPing(uint32_t iPacketCounter = 0, uint32_t iRemotePacketCounter = 0);
339 
340 protected:
342  uint32_t iPacketCounter;
343 
344 public:
345  uint32_t getTravelTime() const;
346  uint32_t getPacketCounter() const { return iPacketCounter; }
347 
348  void CompileFunc(StdCompiler *pComp) override;
349 };
350 
352 {
353 public:
354  C4PacketConn();
355  C4PacketConn(const class C4ClientCore &nCCore, uint32_t iConnID, const char *szPassword = nullptr);
356 
357 protected:
358  int32_t iVer;
359  uint32_t iConnID;
362 
363 public:
364  int32_t getVer() const { return iVer; }
365  uint32_t getConnID() const { return iConnID; }
366  const C4ClientCore &getCCore() const { return CCore; }
367  const char *getPassword() const { return Password.getData(); }
368 
369  void CompileFunc(StdCompiler *pComp) override;
370 };
371 
373 {
374 public:
375  C4PacketConnRe();
376  C4PacketConnRe(bool fOK, bool fWrongPassword, const char *szMsg = nullptr);
377 
378 protected:
379  bool fOK, fWrongPassword;
381 
382 public:
383  bool isOK() const { return fOK; }
384  bool isPasswordWrong() const { return fWrongPassword; }
385  const char *getMsg() const { return szMsg.getData(); }
386 
387  void CompileFunc(StdCompiler *pComp) override;
388 };
389 
390 class C4PacketFwd : public C4PacketBase
391 {
392 public:
393  C4PacketFwd();
394  C4PacketFwd(const StdBuf &Pkt);
395 
396 protected:
397  bool fNegativeList{false};
398  int32_t iClients[C4NetMaxClients];
399  int32_t iClientCnt{0};
401 
402 public:
403  const StdCopyBuf &getData() const { return Data; }
404  bool isNegativeList() const { return fNegativeList; }
405  int32_t getClient(int32_t i) const { return iClients[i]; }
406  int32_t getClientCnt() const { return iClientCnt; }
407 
408  bool DoFwdTo(int32_t iClient) const;
409 
410  void SetData(const StdBuf &Pkt);
411  void SetListType(bool fnNegativeList);
412  void AddClient(int32_t iClient);
413 
414  void CompileFunc(StdCompiler *pComp) override;
415 };
416 
418 {
419 public:
421  ~C4PacketPostMortem() override;
422 
423 private:
424  uint32_t iConnID;
425  uint32_t iPacketCounter; // last packet counter of dead connection
426  uint32_t iPacketCount{0};
427  struct PacketLink
428  {
429  C4NetIOPacket Pkt;
430  PacketLink *Next;
431  };
432  PacketLink *pPackets{nullptr};
433 
434 public:
435  uint32_t getConnID() const { return iConnID; }
436  uint32_t getPacketCount() const { return iPacketCount; }
437  void SetConnID(uint32_t inConnID) { iConnID = inConnID; }
438 
439  const C4NetIOPacket *getPacket(uint32_t iNumber) const;
440  void SetPacketCounter(uint32_t iPacketCounter);
441  void Add(const C4NetIOPacket &rPkt);
442 
443  void CompileFunc(StdCompiler *pComp) override;
444 };
445 
446 #endif
bool fExclusiveConn
Definition: C4Network2IO.h:90
C4NetIO * pNetIO_UDP
Definition: C4Network2IO.h:55
int getConnectionCount()
bool isHalfAccepted() const
Definition: C4Network2IO.h:288
uint32_t getID() const
Definition: C4Network2IO.h:268
void SetReference(class C4Network2Reference *pReference)
CStdCSec BroadcastCSec
Definition: C4Network2IO.h:72
C4Network2IOConnection * GetConnection(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
StdStrBuf szMsg
Definition: C4Network2IO.h:380
Definition: StdBuf.h:29
void OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const char *szReason) override
int32_t getClient(int32_t i) const
Definition: C4Network2IO.h:405
bool HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnection *pConn, bool fThread)
~C4Network2IO() override
bool isAccepted() const
Definition: C4Network2IO.h:289
void SendPuncherPacket(const C4NetpuncherPacket &, C4NetIO::HostAddress::AddressFamily family)
const int C4NetAcceptTimeout
Definition: C4Network2IO.h:37
void AddAutoAccept(const C4ClientCore &CCore)
CStdCSec ConnListCSec
Definition: C4Network2IO.h:72
bool isOK() const
Definition: C4Network2IO.h:383
C4Network2IOConnection * GetMsgConnection(int iClientID)
bool SendMsgToClient(C4NetIOPacket &rPkt, int iClient)
C4Network2IOProtocol eProt
Definition: C4Network2IO.h:225
bool Connect(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, const char *szPassword=nullptr)
C4Network2IOConnection * GetConnectionByConnAddr(const C4NetIO::addr_t &addr, C4NetIO *pNetIO)
uint32_t iPacketCounter
Definition: C4Network2IO.h:342
C4Network2IOProtocol
Definition: C4Network2IO.h:29
C4NetIO * getNetClass() const
Definition: C4Network2IO.h:264
bool isBroadcastTarget() const
Definition: C4Network2IO.h:292
const C4NetIO::addr_t & getConnectAddr() const
Definition: C4Network2IO.h:267
void OnPacket(const C4NetIOPacket &rPacket, C4NetIO *pNetIO) override
void SetExclusiveConnMode(bool fExclusiveConn)
bool IsReferenceNeeded()
C4NetIO * MsgIO()
uint32_t getPacketCounter() const
Definition: C4Network2IO.h:346
class C4Network2RefServer * pRefServer
Definition: C4Network2IO.h:61
const int C4NetPingFreq
Definition: C4Network2IO.h:35
uint32_t getConnID() const
Definition: C4Network2IO.h:435
CStdCSec & getCCoreCSec()
Definition: C4Network2IO.h:272
bool isHost() const
Definition: C4Client.h:58
C4NetIO::addr_t PeerAddr
Definition: C4Network2IO.h:226
CStdCSec LCCoreCSec
Definition: C4Network2IO.h:68
C4Network2IOProtocol getProtocol() const
Definition: C4Network2IO.h:265
int getProtIRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:153
void ClearAutoAccept()
uint32_t getOutPacketCounter() const
Definition: C4Network2IO.h:284
void Punch(const C4NetIO::addr_t &)
C4TimeMilliseconds tLastExecute
Definition: C4Network2IO.h:93
uint32_t getInPacketCounter() const
Definition: C4Network2IO.h:283
C4ClientCore LCCore
Definition: C4Network2IO.h:67
const C4ClientCore & getCCore() const
Definition: C4Network2IO.h:271
C4Network2IOProtocol getNetIOProt(C4NetIO *pNetIO)
const StdCopyBuf & getData() const
Definition: C4Network2IO.h:403
std::atomic_long iRefCnt
Definition: C4Network2IO.h:261
uint32_t getPacketCount() const
Definition: C4Network2IO.h:436
bool doAutoAccept(const C4ClientCore &CCore, const C4Network2IOConnection &Conn)
uint32_t iNextConnID
Definition: C4Network2IO.h:75
void AddConnection(C4Network2IOConnection *pConn)
bool ConnectWithSocket(const C4NetIO::addr_t &addr, C4Network2IOProtocol eProt, const C4ClientCore &nCCore, std::unique_ptr< C4NetIOTCP::Socket > socket, const char *szPassword=nullptr)
int getProtBCRate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:155
bool OnConn(const C4NetIO::addr_t &addr, const C4NetIO::addr_t &AddrConnect, const C4NetIO::addr_t *pOwnAddr, C4NetIO *pNetIO) override
C4Network2IOConnection * GetConnectionByID(uint32_t iConnID)
void RemoveConnection(C4Network2IOConnection *pConn)
C4NetIO * getNetIO(C4Network2IOProtocol eProt)
C4TimeMilliseconds tLastPing
Definition: C4Network2IO.h:236
bool Broadcast(const C4NetIOPacket &rPkt)
bool isPasswordWrong() const
Definition: C4Network2IO.h:384
CStdCSec AutoAcceptCSec
Definition: C4Network2IO.h:87
void SetAcceptMode(bool fAcceptAll)
int32_t getClientCnt() const
Definition: C4Network2IO.h:406
const char * getPassword() const
Definition: C4Network2IO.h:367
bool fAllowConnect
Definition: C4Network2IO.h:78
const int C4NetPingTimeout
Definition: C4Network2IO.h:38
bool hasTCP() const
Definition: C4Network2IO.h:107
const C4NetIO::addr_t & getPeerAddr() const
Definition: C4Network2IO.h:266
C4NetIO::addr_t PuncherAddrIPv4
Definition: C4Network2IO.h:102
C4InteractiveEventType
void SendConnPackets()
bool BroadcastMsg(const C4NetIOPacket &rPkt)
const char * getData() const
Definition: StdBuf.h:442
C4Network2IOConnection * pConnList
Definition: C4Network2IO.h:71
C4NetIO * DataIO()
void SetLocalCCore(const C4ClientCore &CCore)
uint32_t getRemoteID() const
Definition: C4Network2IO.h:269
bool isConnSent() const
Definition: C4Network2IO.h:281
void OnThreadEvent(C4InteractiveEventType eEvent, void *pEventData) override
C4NetIO * pNetIO_TCP
Definition: C4Network2IO.h:55
void BeginBroadcast(bool fSelectAll=false)
virtual void OnError(const char *strError, C4NetIO *pNetIO)
const C4ClientCore & getCCore() const
Definition: C4Network2IO.h:366
C4NetIO::addr_t PuncherAddrIPv6
Definition: C4Network2IO.h:102
void EndBroadcast()
uint32_t getConnID() const
Definition: C4Network2IO.h:365
void GenerateStatistics(int iInterval)
void RemoveAutoAccept(const C4ClientCore &CCore)
class C4Network2UPnP * UPnPMgr
Definition: C4Network2IO.h:64
StdCopyStrBuf Password
Definition: C4Network2IO.h:242
const int C4NetTimer
Definition: C4Network2IO.h:34
C4Network2IOConnStatus Status
Definition: C4Network2IO.h:230
C4Network2IOConnection * GetDataConnection(int iClientID)
class C4Network2IODiscover * pNetIODiscover
Definition: C4Network2IO.h:58
time_t getTimestamp() const
Definition: C4Network2IO.h:270
int32_t iVer
Definition: C4Network2IO.h:358
C4Network2IOConnStatus
Definition: C4Network2IO.h:204
int getProtORate(C4Network2IOProtocol eProt) const
Definition: C4Network2IO.h:154
void SetConnID(uint32_t inConnID)
Definition: C4Network2IO.h:437
C4TimeMilliseconds GetNextTick(C4TimeMilliseconds tNow) override
C4TimeMilliseconds tLastPing
Definition: C4Network2IO.h:94
const char * getMsg() const
Definition: C4Network2IO.h:385
bool IsPuncherAddr(const C4NetIO::addr_t &addr) const
int32_t getID() const
Definition: C4Client.h:57
std::unique_ptr< C4NetIOTCP::Socket > TcpSimOpenSocket
Definition: C4Network2IO.h:227
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:341
Definition: C4Network2IO.h:248
C4TimeMilliseconds tLastStatistic
Definition: C4Network2IO.h:97
void CallHandlers(int iHandlers, const class C4IDPacket *pPacket, C4Network2IOConnection *pConn, bool fThread)
bool isNegativeList() const
Definition: C4Network2IO.h:404
bool Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscovery=-1, int16_t iPortRefServer=-1, bool fBroadcast=false, bool enable_upnp=true)
void HandleFwdReq(const class C4PacketFwd &rFwd, C4Network2IOConnection *pBy)
int32_t getVer() const
Definition: C4Network2IO.h:364
const int C4NetStatisticsFreq
Definition: C4Network2IO.h:36
uint16_t GetPort() const
Definition: C4NetIO.cpp:547
bool Execute(int iTimeout, pollfd *) override
C4TimeMilliseconds tLastPong
Definition: C4Network2IO.h:237
void HandlePuncherPacket(const C4NetIOPacket &rPacket)
bool InitPuncher(C4NetIO::addr_t PuncherAddr)
C4ClientCore CCore
Definition: C4Network2IO.h:360
const char * getNetIOName(C4NetIO *pNetIO)
bool isAutoAccepted() const
Definition: C4Network2IO.h:291
StdCopyBuf Data
Definition: C4Network2IO.h:400
uint32_t iConnID
Definition: C4Network2IO.h:359
Definition: C4Network2IO.h:417
const char * getPassword() const
Definition: C4Network2IO.h:280
bool isConnecting() const
Definition: C4Network2IO.h:286
bool hasUDP() const
Definition: C4Network2IO.h:108
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
Definition: C4Real.cpp:9033
int getPacketLoss() const
Definition: C4Network2IO.h:279
StdCopyStrBuf Password
Definition: C4Network2IO.h:361
const int C4NetMaxClients
Definition: C4Network2IO.h:41