Changeset 448 for code/branches/FICN/src/network/dummyclient3.cc
- Timestamp:
- Dec 9, 2007, 11:24:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/dummyclient3.cc
r446 r448 6 6 using namespace network; 7 7 8 int main(){ 8 void sender(){ 9 9 10 network::PacketGenerator pck; 10 11 const int PORT = 55556; … … 15 16 if(str.compare("")==0) 16 17 str="127.0.0.1"; 17 18 18 19 Client client( str, PORT ); 19 20 if ( client.establishConnection() ) 20 21 std::cout << "connection established" << std::endl; 21 22 else std::cout << "problems establishing connection" << std::endl; 22 23 23 24 while (true) { 24 25 26 27 28 25 client.update(); 26 std::cout << "your message: "; 27 std::getline( std::cin, str ); 28 client.sendChat( str ); 29 std::cout << "send message" << std::endl; 29 30 } 31 32 33 30 34 } 35 36 void listener(){ 37 38 const int PORT = 55556; 39 std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl; 40 std::string str; 41 std::getline(std::cin, str); 42 std::cout << "You entered: " << str << std::endl; 43 if(str.compare("")==0) 44 str="127.0.0.1"; 45 46 Client client( str, PORT ); 47 if ( client.establishConnection() ) 48 std::cout << "connection established" << std::endl; 49 else std::cout << "problems establishing connection" << std::endl; 50 51 while (true) { 52 client.update(); 53 usleep(100); 54 } 55 56 57 58 } 59 60 61 int main(int argc, char **argv[]){ 62 std::string in; 63 std::cout << "Please choose: sender(s) oder listener(l)" << std::endl; 64 std::getline(std::cin, in); 65 if(in.compare("l")==0) 66 listener(); 67 else if(in.compare("s")==0) 68 sender(); 69 else 70 std::cout << "wrong answer" << std::endl; 71 }
Note: See TracChangeset
for help on using the changeset viewer.