Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5811 in orxonox.OLD for branches


Ignore:
Timestamp:
Nov 28, 2005, 11:00:57 PM (19 years ago)
Author:
patrick
Message:

network: again some changes in the functino arguments order, more test abilities in the network subproject

Location:
branches/network/src
Files:
4 edited

Legend:

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

    r5805 r5811  
    141141  PRINTF(0)("Create a new server socket\n");
    142142  /* creating a new network stream, it will register itself automaticaly to the class list */
    143   NetworkStream* netStream = new NetworkStream(sync, port, NET_SERVER);
     143  NetworkStream* netStream = new NetworkStream(port, sync, NET_SERVER);
    144144}
    145145
  • branches/network/src/lib/network/network_stream.cc

    r5810 r5811  
    6262
    6363
    64 NetworkStream::NetworkStream(Synchronizeable& sync, unsigned int port, NodeType type)
     64NetworkStream::NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type)
    6565  : DataStream()
    6666{
  • branches/network/src/lib/network/network_stream.h

    r5809 r5811  
    3131  NetworkStream();
    3232  NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type);
    33   NetworkStream(Synchronizeable& sync, unsigned int port, NodeType type);
     33  NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type);
    3434  ~NetworkStream();
    3535
  • branches/network/src/subprojects/network/network_unit_test.cc

    r5808 r5811  
    166166
    167167
     168
     169/**
     170 *
     171 * @param argc
     172 * @param argv
     173 * @return
     174 */
     175int startServer(int argc, char** argv)
     176{
     177  if( argc <= 2) {
     178    printf(" Wrong arguments try following notations:\n");
     179    printf("   --server [port number]\n");
     180    return 0;
     181  }
     182
     183  int port = atoi(argv[2]);
     184  printf("Starting Server on port %i\n", port);
     185
     186  NetworkManager* netMan = new NetworkManager();
     187  Synchronizeable* ss = new SimpleSync("Server\0");
     188
     189  //NetworkStream* server = new NetworkStream(port, ss, NET_SERVER);
     190  netMan->createServer(*ss, port);
     191
     192  return 0;
     193}
     194
     195
     196int startClient(int argc, char** argv)
     197{
     198  if( argc < 3) {
     199    printf(" Wrong arguments try following notations:\n");
     200    printf("   --client [server ip] [port number]\n");
     201    printf("   --server [server name] [port number]\n");
     202    return 0;
     203  }
     204
     205  char* name = argv[2];
     206  int port = atoi(argv[3]);
     207  printf("Connecting to %s, on port %i\n", name, port);
     208
     209  IPaddress ip;
     210  int error = SDLNet_ResolveHost(&ip, name, port);
     211  //SDLNet_ResolveHost(&ip, "localhost", port);
     212  if(error == -1) printf("\n\nerror on address resolution, program inconsistancy\n\n");
     213
     214  NetworkManager* netMan = new NetworkManager();
     215  Synchronizeable* ss = new SimpleSync("Client\0");
     216
     217  netMan->establishConnection(ip, *ss);
     218
     219
     220  //NetworkStream* client = new NetworkStream(ip, ss, NET_CLIENT);
     221
     222
     223  delete netMan;
     224  delete ss;
     225
     226  return 0;
     227}
     228
     229
     230
    168231/**
    169232 *
     
    174237int main(int argc, char** argv)
    175238{
     239  int i;
    176240  // here the pre-arguments are loaded, these are needed to go either to orxonx itself, Help, or Benchmark.
    177   int i;
    178241  for(i = 1; i < argc; ++i)
    179242  {
    180243    //else if(!strcmp( "--gui", argv[i]) || !strcmp("-g", argv[i])) showGui = true;
    181     if (! strcmp( "--sockettest", argv[i]) || !strcmp("-s", argv[i])) return testSocket(argc, argv);
    182     else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-f", argv[i])) return testFramework(argc, argv);
     244    if (! strcmp( "--sockettest", argv[i]) || !strcmp("-st", argv[i])) return testSocket(argc, argv);
     245    else if (! strcmp( "--frameworktest", argv[i]) || !strcmp("-ft", argv[i])) return testFramework(argc, argv);
     246    else if (! strcmp( "--server", argv[i]) || !strcmp("-s", argv[i])) return startServer(argc, argv);
     247    else if (! strcmp( "--client", argv[i]) || !strcmp("-c", argv[i])) return startClient(argc, argv);
    183248  }
    184249
Note: See TracChangeset for help on using the changeset viewer.