Changeset 5630 in orxonox.OLD for branches/network/src/subprojects
- Timestamp:
- Nov 18, 2005, 2:21:30 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/subprojects/network/network_unit_test.cc
r5628 r5630 27 27 SDLNet_ResolveHost(&ip, "127.0.0.1", 9999); 28 28 server.listen(9999); 29 SDL_Delay(20); 29 30 client.connectToServer(ip, 9999); 30 31 char buf[1024]; … … 37 38 38 39 int n; 39 40 char * str1 = "client to server"; 40 41 char * str2 = "server to client"; 41 42 n = client.writeBytes((byte*)str1, strlen(str1)+1); 42 43 printf("%d bytes send from client\n", n); 43 44 n = server.writeBytes((byte*)str2, strlen(str2)+1); 44 45 printf("%d bytes send from server\n", n); 45 46 SDL_Delay(1000); 46 47 47 48 printf("read from server\n"); 48 49 n = server.readBytes((byte*)buf, 1024); … … 63 64 printf("testing a bigger amount of data\n"); 64 65 65 #define _N_ELEMENTS 212992 66 char sendbuf[_N_ELEMENTS]; 67 char recvbuf[_N_ELEMENTS]; 66 #define _N_ELEMENTS 212994 67 char sendbuf[_N_ELEMENTS+1]; 68 char recvbuf[_N_ELEMENTS+1]; 69 sendbuf[_N_ELEMENTS] = '\0'; 70 recvbuf[_N_ELEMENTS] = '\0'; 68 71 69 72 for (int i = 0; i<_N_ELEMENTS; i++) 70 sendbuf[i] = i% 30 + 30;73 sendbuf[i] = i%26 + 65; 71 74 72 75 printf("write\n"); 73 client.writeBytes((byte*)sendbuf, _N_ELEMENTS);76 printf("result = %d\n", client.writeBytes((byte*)sendbuf, _N_ELEMENTS)); 74 77 75 SDL_Delay(50 0);78 SDL_Delay(50); 76 79 77 80 printf("read\n"); … … 82 85 { 83 86 SDL_Delay(10); 84 printf("read\n");87 //printf("read\n"); 85 88 nbytes = server.readBytes((byte*)recvbuf+offset, _N_ELEMENTS-offset); 86 89 offset += nbytes; 87 printf("nbytes=%d, offset=%d\n", nbytes, offset);90 //printf("nbytes=%d, offset=%d\n", nbytes, offset); 88 91 } 89 92 90 93 printf("strcmp = %d (0 is good :D not 0 is evil)\noffset = %d\n", strncmp(sendbuf, recvbuf, _N_ELEMENTS), offset); 94 95 //printf("%s\n%s\n", sendbuf, recvbuf); 96 97 for (int i = 0; i<_N_ELEMENTS; i++) 98 { 99 if (sendbuf[i]!=recvbuf[i]) 100 { 101 printf("byte %d is the first difference\n", i+1); 102 break; 103 } 104 } 91 105 92 106 return 0;
Note: See TracChangeset
for help on using the changeset viewer.