Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6139 in orxonox.OLD for trunk/src/subprojects/network


Ignore:
Timestamp:
Dec 16, 2005, 6:45:32 PM (19 years ago)
Author:
patrick
Message:

trunk: merged branche network with trunk using command: svn merge -r5999:HEAD, conflicts resolved in favor of the trunk bla

Location:
trunk/src/subprojects/network
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/subprojects/network/Makefile.am

    r5996 r6139  
    1111network_LDADD = $(MAINSRCDIR)/lib/network/libORXnet.a \
    1212                \
    13                 $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a
     13                $(MAINSRCDIR)/lib/parser/tinyxml/libtinyxml.a
    1414
    1515network_SOURCES=  network_unit_test.cc \
  • trunk/src/subprojects/network/network_unit_test.cc

    r5996 r6139  
    1111#include "network_stream.h"
    1212#include "synchronizeable.h"
     13#include "converter.h"
    1314
    1415#include "simple_sync.h"
     
    4041  server.listen(9999);
    4142
    42   NetworkSocket client1(ip);
    43 
    44   NetworkSocket server1 = server.getNewSocket();
    45 
    46   NetworkSocket client2(ip);
    47 
    48   NetworkSocket server2 = server.getNewSocket();
     43  NetworkSocket* client1 = new NetworkSocket(ip);
     44
     45  NetworkSocket* server1 = server.getNewSocket();
     46
     47  NetworkSocket* client2 = new NetworkSocket(ip);
     48
     49  NetworkSocket* server2 = server.getNewSocket();
    4950
    5051  char buf[1024];
    5152
    5253  printf("read from client1 before sending data\n");
    53   printf("result: %d bytes\n", client1.readPacket((byte*)buf, 1024));
     54  printf("result: %d bytes\n", client1->readPacket((byte*)buf, 1024));
    5455
    5556  printf("read from client2 before sending data\n");
    56   printf("result: %d bytes\n", client2.readPacket((byte*)buf, 1024));
     57  printf("result: %d bytes\n", client2->readPacket((byte*)buf, 1024));
    5758
    5859  int n;
     
    6162  char * str3 = "client2 to server";
    6263  char * str4 = "server2 to client";
    63   n = client1.writePacket((byte*)str1, strlen(str1)+1);
     64  n = client1->writePacket((byte*)str1, strlen(str1)+1);
    6465  printf("%d bytes send from client1\n", n);
    65   n = server1.writePacket((byte*)str2, strlen(str2)+1);
     66  n = server1->writePacket((byte*)str2, strlen(str2)+1);
    6667  printf("%d bytes send from server1\n", n);
    67   n = client2.writePacket((byte*)str3, strlen(str3)+1);
     68  n = client2->writePacket((byte*)str3, strlen(str3)+1);
    6869  printf("%d bytes send from client2\n", n);
    69   n = server2.writePacket((byte*)str4, strlen(str4)+1);
     70  n = server2->writePacket((byte*)str4, strlen(str4)+1);
    7071  printf("%d bytes send from server2\n", n);
    7172  SDL_Delay(1000);
    7273
    7374  printf("read from server1\n");
    74   n = server1.readPacket((byte*)buf, 1024);
     75  n = server1->readPacket((byte*)buf, 1024);
    7576  printf("read %d bytes\n", n);
    7677  if (n<0)
     
    8081
    8182  printf("read from server2\n");
    82   n = server2.readPacket((byte*)buf, 1024);
     83  n = server2->readPacket((byte*)buf, 1024);
    8384  printf("read %d bytes\n", n);
    8485  if (n<0)
     
    8889
    8990  printf("read from client1\n");
    90   n = client1.readPacket((byte*)buf, 1024);
     91  n = client1->readPacket((byte*)buf, 1024);
    9192  printf("read %d bytes\n", n);
    9293  if (n<0)
     
    9697
    9798  printf("read from client2\n");
    98   n = client2.readPacket((byte*)buf, 1024);
     99  n = client2->readPacket((byte*)buf, 1024);
    99100  printf("read %d bytes\n", n);
    100101  if (n<0)
     
    106107
    107108  printf("try to send more than 255 bytes\n");
    108   printf("result: %d\n", client1.writePacket((byte*)buf, 1000));
    109 
    110   server1.writePacket((byte*)str1, strlen(str1)+1);
     109  printf("result: %d\n", client1->writePacket((byte*)buf, 1000));
     110
     111  server1->writePacket((byte*)str1, strlen(str1)+1);
    111112  SDL_Delay(500);
    112113  printf("try to read with a too small buffer\n");
    113   printf("result: %d\n", client1.readPacket((byte*)buf, strlen(str1)));
     114  printf("result: %d\n", client1->readPacket((byte*)buf, strlen(str1)));
    114115
    115116  return 0;
     
    190191  Synchronizeable* ss = new SimpleSync("Server\0");
    191192
    192   netMan->createServer(*ss, port);
     193  netMan->createServer(/**ss, */port);
    193194  SDL_Delay(20);
    194195
     
    196197  {
    197198    netMan->synchronize();
    198     SDL_Delay(500);
     199    SDL_Delay(1000);
    199200  }
    200201
     
    229230  Synchronizeable* ss = new SimpleSync("Client\0");
    230231
    231   netMan->establishConnection(ip, *ss);
     232  netMan->establishConnection((const char*)"localhost", port/*,ip, *ss*/);
    232233
    233234  for(;;)
     
    280281  delete ss;
    281282
     283  return 0;
     284}
     285
     286
     287int converter(int argc, char** argv)
     288{
     289  int x = 200564786;
     290  printf("To convert: %i\n", x);
     291  byte* res = Converter::intToByteArray(x);
     292  for (int i = 0; i < 4; i++)
     293    printf("%i  ", res[i]);
     294  printf("\n");
     295 
     296  int z = Converter::byteArrayToInt(res);
     297 
     298  printf("ReConvert: %i\n", z);
     299
     300 
     301  //float a = 5.4f;
     302  //float b = 2.0f;
     303  //printf("%f mod %f = %f", a, b, a % b);
     304 
     305  printf("\n");
     306 
     307  float y;
     308  char* s;
     309 
     310  y = 12.0f;
     311  s = Converter::floatToBinString(y);
     312  printf("%f = ", y);
     313  printf(s); printf("\n");
     314 
     315  y = 24549026.0f;
     316  s = Converter::floatToBinString(y);
     317  printf("%f = ", y);
     318  printf(s); printf("\n");
     319 
     320  y = 12.4e20f;
     321  s = Converter::floatToBinString(y);
     322  printf("%f = ", y);
     323  printf(s); printf("\n");
     324 
     325  y = 4.7824f;
     326  s = Converter::floatToBinString(y);
     327  printf("%f = ", y);
     328  printf(s); printf("\n");
     329 
     330 
     331 
    282332  return 0;
    283333}
     
    308358    else if (! strcmp( "--listen", argv[i]) || !strcmp("-l", argv[i]))
    309359      return startListen(argc, argv);
     360    else if (! strcmp( "--converter", argv[i]) || !strcmp("-o", argv[i]))
     361      return converter(argc, argv);
    310362  }
    311363
  • trunk/src/subprojects/network/read_sync.cc

    r5996 r6139  
    8080 *  read data from Synchronizeable
    8181 */
    82 int ReadSync::readBytes(byte* data)
     82int ReadSync::readBytes(byte* data, int maxLength, int * reciever)
    8383{
    8484  return 0;
  • trunk/src/subprojects/network/read_sync.h

    r5996 r6139  
    1717
    1818    virtual void writeBytes(const byte* data, int length);
    19     virtual int readBytes(byte* data);
     19    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
    2121
  • trunk/src/subprojects/network/simple_sync.cc

    r5996 r6139  
    8686 *  read data from Synchronizeable
    8787 */
    88 int SimpleSync::readBytes(byte* data)
     88int SimpleSync::readBytes(byte* data, int maxLength, int * reciever)
    8989{
    9090  PRINTF(0)("SimpleSync: sent %i bytes of data\n", this->outLength);
  • trunk/src/subprojects/network/simple_sync.h

    r5996 r6139  
    1717
    1818    virtual void writeBytes(const byte* data, int length);
    19     virtual int readBytes(byte* data);
     19    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
    2121
  • trunk/src/subprojects/network/write_sync.cc

    r5996 r6139  
    8686 *  read data from Synchronizeable
    8787 */
    88 int WriteSync::readBytes(byte* data)
     88int WriteSync::readBytes(byte* data, int maxLength, int * reciever)
    8989{
    9090  PRINTF(0)("WriteSync: sent %i bytes of data\n", this->outLength);
  • trunk/src/subprojects/network/write_sync.h

    r5996 r6139  
    1717
    1818    virtual void writeBytes(const byte* data, int length);
    19     virtual int readBytes(byte* data);
     19    virtual int readBytes(byte* data, int maxLength, int * reciever);
    2020
    2121
Note: See TracChangeset for help on using the changeset viewer.