Advertisement
Guest User

Untitled

a guest
Jul 15th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <SFML/Network.hpp>
  3.  
  4. using namespace sf;
  5.  
  6. void client()
  7. {
  8.     TcpSocket client;
  9.     std::cout << "Connecting\n";
  10.     if( client.connect( "127.0.0.1", 55000 ) != Socket::Done )
  11.     {
  12.         std::cout << "Client does not werk.\n";
  13.     }
  14.     std::cout << "Client end\n";
  15. }
  16.  
  17. void server()
  18. {
  19.     TcpListener server;
  20.     TcpSocket connection;
  21.     std::cout << "Listening\n";
  22.     server.listen( 55000 );
  23.     std::cout << "Accepting\n";
  24.     if( server.accept( connection ) != Socket::Done )
  25.     {
  26.         std::cout << "Server does not werk.\n";
  27.     }
  28.     std::cout << "Server end\n";
  29. }
  30.  
  31. int main()
  32. {
  33.     char ch;
  34.     std::cin >> ch;
  35.     if( ch == 's' )
  36.     {
  37.         server();
  38.     }
  39.     else
  40.     {
  41.         client();
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement