Changeset 6026 in orxonox.OLD for branches/network
- Timestamp:
- Dec 10, 2005, 9:57:51 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_socket.cc
r6025 r6026 27 27 /* header for debug output */ 28 28 #include "debug.h" 29 30 static SDL_mutex* threadTerminationMutex = SDL_CreateMutex();31 29 32 30 /** … … 305 303 } 306 304 307 SDL_mutexP( threadTerminationMutex);305 SDL_mutexP(self->threadTerminationMutex); 308 306 self->thread_read_running = false; 309 307 310 308 if ( !self->thread_write_running ) 309 { 310 SDL_mutexV(self->threadTerminationMutex); 311 311 delete self; 312 SDL_mutexV(threadTerminationMutex); 312 } 313 313 314 314 315 printf("QUIT READ THREAD\n"); … … 365 366 } 366 367 367 SDL_mutexP( threadTerminationMutex);368 SDL_mutexP(self->threadTerminationMutex); 368 369 self->thread_write_running = false; 369 370 370 371 if ( !self->thread_read_running ) 372 { 373 SDL_mutexV(self->threadTerminationMutex); 371 374 delete self; 372 SDL_mutexV(threadTerminationMutex); 375 } 376 373 377 374 378 printf("QUIT WRITE THREAD\n"); -
branches/network/src/lib/network/network_socket.h
r6025 r6026 63 63 bool terminateThread; 64 64 65 staticSDL_mutex* threadTerminationMutex;65 SDL_mutex* threadTerminationMutex; 66 66 static int thread_read(void * data); 67 67 bool thread_read_running; -
branches/network/src/subprojects/network/network_unit_test.cc
r6025 r6026 40 40 server.listen(9999); 41 41 42 NetworkSocket client1(ip);42 NetworkSocket* client1 = new NetworkSocket(ip); 43 43 44 44 NetworkSocket* server1 = server.getNewSocket(); 45 45 46 NetworkSocket client2(ip);46 NetworkSocket* client2 = new NetworkSocket(ip); 47 47 48 48 NetworkSocket* server2 = server.getNewSocket(); … … 51 51 52 52 printf("read from client1 before sending data\n"); 53 printf("result: %d bytes\n", client1 .readPacket((byte*)buf, 1024));53 printf("result: %d bytes\n", client1->readPacket((byte*)buf, 1024)); 54 54 55 55 printf("read from client2 before sending data\n"); 56 printf("result: %d bytes\n", client2 .readPacket((byte*)buf, 1024));56 printf("result: %d bytes\n", client2->readPacket((byte*)buf, 1024)); 57 57 58 58 int n; … … 61 61 char * str3 = "client2 to server"; 62 62 char * str4 = "server2 to client"; 63 n = client1 .writePacket((byte*)str1, strlen(str1)+1);63 n = client1->writePacket((byte*)str1, strlen(str1)+1); 64 64 printf("%d bytes send from client1\n", n); 65 65 n = server1->writePacket((byte*)str2, strlen(str2)+1); 66 66 printf("%d bytes send from server1\n", n); 67 n = client2 .writePacket((byte*)str3, strlen(str3)+1);67 n = client2->writePacket((byte*)str3, strlen(str3)+1); 68 68 printf("%d bytes send from client2\n", n); 69 69 n = server2->writePacket((byte*)str4, strlen(str4)+1); … … 88 88 89 89 printf("read from client1\n"); 90 n = client1 .readPacket((byte*)buf, 1024);90 n = client1->readPacket((byte*)buf, 1024); 91 91 printf("read %d bytes\n", n); 92 92 if (n<0) … … 96 96 97 97 printf("read from client2\n"); 98 n = client2 .readPacket((byte*)buf, 1024);98 n = client2->readPacket((byte*)buf, 1024); 99 99 printf("read %d bytes\n", n); 100 100 if (n<0) … … 106 106 107 107 printf("try to send more than 255 bytes\n"); 108 printf("result: %d\n", client1 .writePacket((byte*)buf, 1000));108 printf("result: %d\n", client1->writePacket((byte*)buf, 1000)); 109 109 110 110 server1->writePacket((byte*)str1, strlen(str1)+1); 111 111 SDL_Delay(500); 112 112 printf("try to read with a too small buffer\n"); 113 printf("result: %d\n", client1 .readPacket((byte*)buf, strlen(str1)));113 printf("result: %d\n", client1->readPacket((byte*)buf, strlen(str1))); 114 114 115 115 return 0;
Note: See TracChangeset
for help on using the changeset viewer.