Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5630 in orxonox.OLD for branches/network/src/subprojects


Ignore:
Timestamp:
Nov 18, 2005, 2:21:30 PM (19 years ago)
Author:
rennerc
Message:

network_socket: uses now a thread to send

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/subprojects/network/network_unit_test.cc

    r5628 r5630  
    2727  SDLNet_ResolveHost(&ip, "127.0.0.1", 9999);
    2828  server.listen(9999);
     29  SDL_Delay(20);
    2930  client.connectToServer(ip, 9999);
    3031  char buf[1024];
     
    3738
    3839  int n;
    39         char * str1 = "client to server";
     40  char * str1 = "client to server";
    4041  char * str2 = "server to client";
    4142  n = client.writeBytes((byte*)str1, strlen(str1)+1);
    42         printf("%d bytes send from client\n", n);
     43  printf("%d bytes send from client\n", n);
    4344  n = server.writeBytes((byte*)str2, strlen(str2)+1);
    44         printf("%d bytes send from server\n", n);
     45  printf("%d bytes send from server\n", n);
    4546  SDL_Delay(1000);
    46  
     47
    4748  printf("read from server\n");
    4849  n = server.readBytes((byte*)buf, 1024);
     
    6364  printf("testing a bigger amount of data\n");
    6465
    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';
    6871
    6972  for (int i = 0; i<_N_ELEMENTS; i++)
    70     sendbuf[i] = i%30 + 30;
     73    sendbuf[i] = i%26 + 65;
    7174
    7275  printf("write\n");
    73   client.writeBytes((byte*)sendbuf, _N_ELEMENTS);
     76  printf("result = %d\n", client.writeBytes((byte*)sendbuf, _N_ELEMENTS));
    7477
    75   SDL_Delay(500);
     78  SDL_Delay(50);
    7679
    7780  printf("read\n");
     
    8285  {
    8386    SDL_Delay(10);
    84     printf("read\n");
     87    //printf("read\n");
    8588    nbytes = server.readBytes((byte*)recvbuf+offset, _N_ELEMENTS-offset);
    8689    offset += nbytes;
    87     printf("nbytes=%d, offset=%d\n", nbytes, offset);
     90    //printf("nbytes=%d, offset=%d\n", nbytes, offset);
    8891  }
    8992
    9093  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  }
    91105
    92106  return 0;
Note: See TracChangeset for help on using the changeset viewer.