#pragma comment(lib, "sfml-network.lib")
#include <iostream>
#include <SFML/Network.hpp>
sf::TcpListener listener;
sf::TcpSocket socket;
sf::Packet packet;
sf::IpAddress ip = sf::IpAddress::getLocalAddress();
std::string text;
void Server()
{
listener.listen(2000);
listener.accept(socket);
text = "Hello";
packet << text;
socket.send(packet);
}
void Client()
{
socket.connect(ip, 2000);
socket.receive(packet);
packet >> text;
}
int main()
{
char who;
std::cout << "Do you want to be a server (s) or a client (c) ? ";
std::cin >> who;
if (who == 's')
Server();
else
Client();
std::cout << text << std::endl;
system("pause");
return 0;
}