MCPcopy Create free account
hub / github.com/ddnet/ddnet / Open

Method Open

src/engine/shared/network_server.cpp:41–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 0x00, 0x05};
40
41bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIp)
42{
43 // zero out the whole structure
44 this->~CNetServer();
45 new(this) CNetServer{};
46
47 // open socket
48 m_Socket = net_udp_create(BindAddr);
49 if(!m_Socket)
50 return false;
51
52 m_Address = BindAddr;
53 m_pNetBan = pNetBan;
54
55 m_MaxClients = std::clamp(MaxClients, 1, (int)NET_MAX_CLIENTS);
56 m_MaxClientsPerIp = MaxClientsPerIp;
57
58 m_VConnNum = 0;
59 m_VConnFirst = 0;
60
61 secure_random_fill(m_aSecurityTokenSeed, sizeof(m_aSecurityTokenSeed));
62
63 for(auto &Slot : m_aSlots)
64 Slot.m_Connection.Init(m_Socket, true);
65
66 return true;
67}
68
69int CNetServer::SetCallbacks(NETFUNC_NEWCLIENT pfnNewClient, NETFUNC_DELCLIENT pfnDelClient, void *pUser)
70{

Callers

nothing calls this directly

Calls 3

net_udp_createFunction · 0.85
secure_random_fillFunction · 0.85
InitMethod · 0.45

Tested by

no test coverage detected