MCPcopy Create free account
hub / github.com/assaultcube/AC / setupserver

Function setupserver

source/src/master.cpp:232–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232void setupserver(int port, const char *ip = NULL)
233{
234 ENetAddress address;
235 address.host = ENET_HOST_ANY;
236 address.port = port;
237
238 if(ip)
239 {
240 if(enet_address_set_host(&address, ip)<0)
241 fatal("failed to resolve server address: %s", ip);
242 }
243 serversocket = enet_socket_create(ENET_SOCKET_TYPE_STREAM);
244 if(serversocket==ENET_SOCKET_NULL ||
245 enet_socket_set_option(serversocket, ENET_SOCKOPT_REUSEADDR, 1) < 0 ||
246 enet_socket_bind(serversocket, &address) < 0 ||
247 enet_socket_listen(serversocket, -1) < 0)
248 fatal("failed to create server socket");
249 if(enet_socket_set_option(serversocket, ENET_SOCKOPT_NONBLOCK, 1)<0)
250 fatal("failed to make server socket non-blocking");
251 if(!setuppingsocket())
252 fatal("failed to create ping socket");
253
254 enet_time_set(0);
255
256 starttime = time(NULL);
257 char *ct = ctime(&starttime);
258 if(strchr(ct, '\n')) *strchr(ct, '\n') = '\0';
259 conoutf("*** Starting master server on %s %d at %s ***", ip ? ip : "localhost", port, ct);
260}
261
262void genserverlist()
263{

Callers 1

mainFunction · 0.85

Calls 9

setuppingsocketFunction · 0.85
fatalFunction · 0.70
conoutfFunction · 0.70
enet_address_set_hostFunction · 0.50
enet_socket_createFunction · 0.50
enet_socket_set_optionFunction · 0.50
enet_socket_bindFunction · 0.50
enet_socket_listenFunction · 0.50
enet_time_setFunction · 0.50

Tested by

no test coverage detected