- Timestamp:
- May 8, 2006, 11:55:55 AM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/udp_server_socket.cc
r7553 r7556 44 44 for ( int i = 0; i < packetBuffer.size(); i++ ) 45 45 removeUserPackets( i ); 46 47 if ( packet ) 48 SDLNet_FreePacket( packet ); 49 50 if ( socket ) 51 SDLNet_UDP_Close( socket ); 46 52 } 47 53 … … 106 112 NetworkPacket networkPacket; 107 113 networkPacket.length = packet->len; 108 networkPacket.data = (byte*)malloc( packet->len ); 109 assert( networkPacket.data ); 114 if ( packet->len != 0 ) 115 { 116 networkPacket.data = (byte*)malloc( packet->len ); 117 assert( networkPacket.data ); 118 } 119 else 120 networkPacket.data = NULL; 110 121 memcpy( networkPacket.data, packet->data, packet->len ); 111 122 packetBuffer[userId].push_back( networkPacket ); … … 155 166 if ( it->data ) 156 167 { 157 delete it->data;168 free( it->data ); 158 169 it->data = NULL; 159 170 } … … 253 264 memcpy( packet->data, networkPacket.data, networkPacket.length ); 254 265 packet->len = networkPacket.length; 266 packet->channel = -1; 255 267 256 268 if ( SDLNet_UDP_Send( socket, userId, packet ) == 0 ) -
branches/network/src/lib/network/udp_socket.cc
r7553 r7556 68 68 this->init(); 69 69 this->serverSocket = serverSocket; 70 this->userId = userId; 70 71 } 71 72 … … 73 74 * destructor 74 75 */ 75 UdpSocket::~ 76 UdpSocket::~UdpSocket( ) 76 77 { 77 78 if ( serverSocket ) … … 79 80 80 81 disconnectServer(); 82 83 if ( this->packet ) 84 SDLNet_FreePacket( this->packet ); 85 86 if ( socket ) 87 SDLNet_UDP_Close( socket ); 81 88 } 82 89 … … 186 193 if ( networkPacket.data ) 187 194 { 188 delete networkPacket.data;195 free( networkPacket.data ); 189 196 networkPacket.data = NULL; 190 197 } -
branches/network/src/subprojects/network/network_unit_test.cc
r7553 r7556 112 112 113 113 //sending bigger packets than 255 is not supported 114 114 #if 0 115 115 printf("try to send more than 255 bytes\n"); 116 116 printf("result: %d\n", client1->writePacket((byte*)buf, 1000)); … … 120 120 printf("try to read with a too small buffer\n"); 121 121 printf("result: %d\n", client1->readPacket((byte*)buf, strlen(str1))); 122 122 #endif 123 124 delete client1; 125 delete client2; 126 delete server1; 127 delete server2; 128 123 129 return 0; 124 130 }
Note: See TracChangeset
for help on using the changeset viewer.