MCPcopy Index your code
hub / github.com/assaultcube/AC / connectmaster

Function connectmaster

source/src/serverms.cpp:46–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46ENetSocket connectmaster()
47{
48 if(!mastername[0] || !usemaster) return ENET_SOCKET_NULL;
49
50 if(masteraddress.host == ENET_HOST_ANY)
51 {
52 xlog(ACLOG_INFO, "looking up %s:%d...", mastername, masterport);
53 masteraddress.port = masterport;
54 if(!resolverwait(mastername, &masteraddress)) return ENET_SOCKET_NULL;
55 }
56 ENetSocket sock = enet_socket_create(ENET_SOCKET_TYPE_STREAM);
57 if(sock != ENET_SOCKET_NULL && serveraddress.host != ENET_HOST_ANY && enet_socket_bind(sock, &serveraddress) < 0)
58 {
59 enet_socket_destroy(sock);
60 sock = ENET_SOCKET_NULL;
61 }
62 if(sock == ENET_SOCKET_NULL || connectwithtimeout(sock, mastername, masteraddress) < 0)
63 {
64 xlog(ACLOG_WARNING, sock==ENET_SOCKET_NULL ? "could not open socket" : "could not connect");
65 return ENET_SOCKET_NULL;
66 }
67
68 enet_socket_set_option(sock, ENET_SOCKOPT_NONBLOCK, 1);
69 return sock;
70}
71
72bool requestmaster(const char *req)
73{

Callers 2

retrieveserversFunction · 0.85
requestmasterFunction · 0.85

Calls 7

xlogFunction · 0.85
resolverwaitFunction · 0.70
connectwithtimeoutFunction · 0.70
enet_socket_createFunction · 0.50
enet_socket_bindFunction · 0.50
enet_socket_destroyFunction · 0.50
enet_socket_set_optionFunction · 0.50

Tested by

no test coverage detected