Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/dummyclient3.cc @ 777

Last change on this file since 777 was 777, checked in by rgrieder, 16 years ago
  • added dll support to the network library
  • improved header file dependency in network
File size: 1.8 KB
Line 
1#include <iostream>
2#include <string>
3
4#include "util/Sleep.h"
5#include "PacketManager.h"
6#include "Client.h"
7
8using namespace network;
9
10void sender(){
11
12  network::PacketGenerator pck;
13  const int PORT = 55556;
14  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
15  std::string str;
16  std::getline(std::cin, str);
17  std::cout << "You entered: " << str << std::endl;
18  if(str.compare("")==0)
19    str="127.0.0.1";
20
21  Client client( str, PORT );
22  if ( client.establishConnection() )
23    std::cout << "connection established" << std::endl;
24  else std::cout << "problems establishing connection" << std::endl;
25  char message[10000];
26  char signs[] = "abcdefghijklmnopqrstuvwxy";
27  while (true) {
28    client.tick(0);
29
30    std::cout << "your message2: ";
31    for ( int i=0; i<9999; i++ ) {
32      message[i] = signs[0];
33    }
34    message[9999] = 'z';
35    std::string str( message );
36    client.sendChat( str );
37    std::cout << str << std::endl;
38    std::cin.get(); std::cin.get();
39  }
40
41
42
43}
44
45void listener(){
46
47  const int PORT = 55556;
48  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
49  std::string str;
50  std::getline(std::cin, str);
51  std::cout << "You entered: " << str << std::endl;
52  if(str.compare("")==0)
53    str="127.0.0.1";
54
55  Client client( str, PORT );
56  if ( client.establishConnection() )
57    std::cout << "connection established" << std::endl;
58  else std::cout << "problems establishing connection" << std::endl;
59
60  while (true) {
61    client.tick(0);
62    usleep(100);
63  }
64
65
66
67}
68
69
70int main(int argc, char **argv[]){
71  std::string in;
72  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
73  std::getline(std::cin, in);
74  if(in.compare("l")==0)
75    listener();
76  else if(in.compare("s")==0)
77    sender();
78  else
79    std::cout << "wrong answer" << std::endl;
80}
Note: See TracBrowser for help on using the repository browser.