Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/dummyserver.cc @ 436

Last change on this file since 436 was 367, checked in by rgrieder, 17 years ago
  • made certain files windows compatible
  • solved conflict with unresolved external symbol registerAllVariables() by commenting call
File size: 1004 bytes
RevLine 
[196]1//
2// Dummy server to test ConnectionManager and PacketBuffer classes
3//
4// Author: Oliver Scheuss
5
6
7#include <iostream>
[341]8#include <enet/enet.h>
[285]9#include "ConnectionManager.h"
10#include "PacketManager.h"
[196]11
[367]12#ifdef WIN32
13#include <windows.h>
14#define usleep(x) Sleep((x)/1000)
15#else
16#include <unistd.h>
17#endif
[346]18
[367]19
[196]20using namespace network;
21
22int main(){
23  ConnectionManager server = ConnectionManager();
24  bool quit=false;
25  ENetPacket *packet;
26  server.createListener();
[285]27
[204]28  PacketDecoder dec;
[285]29
[196]30  while(!quit){
31    if(server.queueEmpty())
[367]32// Warning: usleep(100) is Sleep(100/1000) = Sleep(0), which is nothing!
[196]33      usleep(100);
34    else{
[204]35      ENetAddress addr;
36      packet=server.getPacket(addr);
[196]37      if(packet==NULL){
38        // there was some error
39        //std::cout << "null pointer" << std::endl;
40        quit=true;
41      }
[204]42      else{
43        //std::cout << "We received: " << packet->data << std::endl;
44        dec.elaborate(packet, 1);
45      }
[196]46    }
47  }
48  server.quitListener();
49  return 0;
50}
Note: See TracBrowser for help on using the repository browser.