Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9308 in orxonox.OLD for branches/proxy/src/lib/network/udp_socket.cc


Ignore:
Timestamp:
Jul 17, 2006, 5:47:32 PM (18 years ago)
Author:
patrick
Message:

proxy server ip synchronizeing bug, nodes get registered

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/udp_socket.cc

    r8802 r9308  
    105105  assert( serverSocket == NULL );
    106106
    107   IPaddress ip;
    108  
    109107  this->randomByte = generateNewRandomByte();
    110108
    111109  PRINTF(0)("connect to server %s on port %d\n", host.c_str(), port);
    112110
    113   if ( SDLNet_ResolveHost( &ip, host.c_str(), port ) != 0 )
     111  if ( SDLNet_ResolveHost( &this->ip, host.c_str(), port ) != 0 )
    114112  {
    115113    PRINTF(1)("SDLNet_ResolveHost: %s\n", SDLNet_GetError() );
     
    126124  }
    127125
    128   int channel = SDLNet_UDP_Bind(socket, 1, &ip);
     126  int channel = SDLNet_UDP_Bind(socket, 1, &this->ip);
    129127  if ( channel == -1 )
    130128  {
     
    147145  bOk = false;
    148146  socket = NULL;
     147
     148  this->ip.host = 0;
     149  this->ip.port = 0;
    149150}
    150151
     
    179180
    180181    byte udpCmd = 0;
    181    
     182
    182183    if ( networkPacket.length > 0 )
    183184    {
     
    189190    else
    190191      return 0;
    191      
     192
    192193    if ( !checkRandomByte( networkPacket.data[0] ) )
    193194      return 0;
     
    198199      networkPacket.data = NULL;
    199200    }
    200    
     201
    201202    if ( !checkUdpCmd( udpCmd ) )
    202203      return 0;
     
    207208  {
    208209    int numrecv = SDLNet_UDP_Recv( socket, packet);
    209    
     210
    210211    byte udpCmd = 0;
    211212
     
    218219      else
    219220        return 0;
    220            
     221
    221222      if ( !checkRandomByte( packet->data[0] ) )
    222223        return 0;
    223              
     224
    224225      if ( !checkUdpCmd( udpCmd ) )
    225226        return 0;
     
    283284    return false;
    284285  }
    285  
     286
    286287  if ( !this->serverSocket && ( udpCmd & UDPCMD_INVALIDRNDBYTE ) )
    287288  {
     
    292293    return false;
    293294  }
    294  
     295
    295296  return true;
    296297}
     
    300301  srand( SDL_GetTicks() );
    301302  byte res = ( rand() & 0xFC );
    302  
     303
    303304  PRINTF(0)("generated random byte: %x\n", res);
    304  
     305
    305306  return res;
    306307}
Note: See TracChangeset for help on using the changeset viewer.