MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / ServerLink

Method ServerLink

src/clientbase/ServerLink.cpp:99–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99ServerLink::ServerLink(const std::string& serverName,
100 const Address& serverAddress, int port)
101 : state(SocketError) // assume failure
102 , fd(-1) // assume failure
103 , udpLength(0)
104 , oldNeedForSpeed(false)
105 , previousFill(0)
106 , joinAddress(serverAddress)
107 , joinServer(serverName)
108 , joinPort(port) {
109 int i;
110
111 struct protoent* p;
112#if defined(_WIN32)
113 BOOL off = FALSE;
114#else
115 int off = 0;
116#endif
117
118 // standard server has no special abilities;
119 server_abilities = Nothing;
120
121 // queue is empty
122
123 urecvfd = -1;
124
125 ulinkup = false;
126
127 // initialize version to a bogus number
128 strcpy(version, "BZFS0000");
129
130 // open connection to server. first connect to given port.
131 // don't wait too long.
132 int query = (int)socket(AF_INET, SOCK_STREAM, 0);
133 if (query < 0) { return; }
134
135 struct sockaddr_in addr;
136 addr.sin_family = AF_INET;
137 addr.sin_port = htons(port);
138 addr.sin_addr = serverAddress;
139
140 UDEBUG("Remote %s\n", inet_ntoa(addr.sin_addr));
141
142 // for UDP, used later
143 memcpy((unsigned char*)&usendaddr, (unsigned char*)&addr, sizeof(addr));
144
145 bool okay = true;
146 int fdMax = query;
147 struct timeval timeout;
148 fd_set write_set;
149 fd_set read_set;
150 int nfound;
151
152#if !defined(_WIN32)
153 // for standard BSD sockets
154
155 // Open a connection.
156 // we are blocking at this point so we will wait till we connect, or error

Callers

nothing calls this directly

Calls 8

debugfFunction · 0.85
getErrnoFunction · 0.85
closeFunction · 0.85
getServerVersionFunction · 0.85
getSecondsMethod · 0.80
isSetMethod · 0.80
evalMethod · 0.80
printErrorFunction · 0.50

Tested by

no test coverage detected