Changeset 9308 in orxonox.OLD for branches/proxy/src/lib/network/udp_socket.cc
- Timestamp:
- Jul 17, 2006, 5:47:32 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/udp_socket.cc
r8802 r9308 105 105 assert( serverSocket == NULL ); 106 106 107 IPaddress ip;108 109 107 this->randomByte = generateNewRandomByte(); 110 108 111 109 PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port); 112 110 113 if ( SDLNet_ResolveHost( & ip, host.c_str(), port ) != 0 )111 if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 ) 114 112 { 115 113 PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() ); … … 126 124 } 127 125 128 int channel = SDLNet_UDP_Bind(socket, 1, & ip);126 int channel = SDLNet_UDP_Bind(socket, 1, &this->ip); 129 127 if ( channel == -1 ) 130 128 { … … 147 145 bOk = false; 148 146 socket = NULL; 147 148 this->ip.host = 0; 149 this->ip.port = 0; 149 150 } 150 151 … … 179 180 180 181 byte udpCmd = 0; 181 182 182 183 if ( networkPacket.length > 0 ) 183 184 { … … 189 190 else 190 191 return 0; 191 192 192 193 if ( !checkRandomByte( networkPacket.data[0] ) ) 193 194 return 0; … … 198 199 networkPacket.data = NULL; 199 200 } 200 201 201 202 if ( !checkUdpCmd( udpCmd ) ) 202 203 return 0; … … 207 208 { 208 209 int numrecv = SDLNet_UDP_Recv( socket, packet); 209 210 210 211 byte udpCmd = 0; 211 212 … … 218 219 else 219 220 return 0; 220 221 221 222 if ( !checkRandomByte( packet->data[0] ) ) 222 223 return 0; 223 224 224 225 if ( !checkUdpCmd( udpCmd ) ) 225 226 return 0; … … 283 284 return false; 284 285 } 285 286 286 287 if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) ) 287 288 { … … 292 293 return false; 293 294 } 294 295 295 296 return true; 296 297 } … … 300 301 srand( SDL_GetTicks() ); 301 302 byte res = ( rand() & 0xFC ); 302 303 303 304 PRINTF(0)("generated random byte: %x\n", res); 304 305 305 306 return res; 306 307 }
Note: See TracChangeset
for help on using the changeset viewer.