Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5628 in orxonox.OLD for branches/network


Ignore:
Timestamp:
Nov 18, 2005, 10:55:08 AM (19 years ago)
Author:
rennerc
Message:

network_unit_test.cc: added test for much data
network_socket: added delay if input buffer is full

Location:
branches/network/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_socket.cc

    r5627 r5628  
    167167  if (res<length)
    168168    PRINTF(1)("SDLNet_TCP_Send: %s\n", SDLNet_GetError());
    169        
    170         return res;
     169
     170  return res;
    171171}
    172172
     
    254254    nbytestoread = min(_INCOMING_BUFFER_SIZE - self->bufferlength, _LOCAL_BUFFER_SIZE);
    255255
     256    //if buffer is full
     257    if (nbytestoread<=0)
     258    {
     259      SDL_Delay(_MSECONDS_SLEEP_FULL_BUFFER);
     260      continue;
     261    }
     262
    256263    nbytesread = SDLNet_TCP_Recv(self->tcpSocket, buffer, nbytestoread);
    257264
     
    282289
    283290
     291
  • branches/network/src/lib/network/network_socket.h

    r5625 r5628  
    1010#define _INCOMING_BUFFER_SIZE 10240
    1111#define _LOCAL_BUFFER_SIZE 1024
     12#define _MSECONDS_SLEEP_FULL_BUFFER 10
    1213
    1314/* contains memmove and memcpy */
  • branches/network/src/subprojects/network/network_unit_test.cc

    r5627 r5628  
    6161  printf("data: %s\n", buf);
    6262
     63  printf("testing a bigger amount of data\n");
     64
     65#define _N_ELEMENTS 212992
     66  char sendbuf[_N_ELEMENTS];
     67  char recvbuf[_N_ELEMENTS];
     68
     69  for (int i = 0; i<_N_ELEMENTS; i++)
     70    sendbuf[i] = i%30 + 30;
     71
     72  printf("write\n");
     73  client.writeBytes((byte*)sendbuf, _N_ELEMENTS);
     74
     75  SDL_Delay(500);
     76
     77  printf("read\n");
     78  int nbytes = server.readBytes((byte*)recvbuf, _N_ELEMENTS);
     79  int offset = nbytes;
     80
     81  while (nbytes>0)
     82  {
     83    SDL_Delay(10);
     84    printf("read\n");
     85    nbytes = server.readBytes((byte*)recvbuf+offset, _N_ELEMENTS-offset);
     86    offset += nbytes;
     87    printf("nbytes=%d, offset=%d\n", nbytes, offset);
     88  }
     89
     90  printf("strcmp = %d (0 is good :D not 0 is evil)\noffset = %d\n", strncmp(sendbuf, recvbuf, _N_ELEMENTS), offset);
     91
    6392  return 0;
    6493}
Note: See TracChangeset for help on using the changeset viewer.