Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sf::RenderWindow window(sf::VideoMode(504, 504), "Server");
- sf::Event e;
- sf::IpAddress ip = sf::IpAddress::getLocalAddress();
- sf::TcpSocket socket;
- int port = 2000;
- sf::Int32 sending[8][8], recieving[8][8];
- sf::TcpListener listener;
- socket.setBlocking(false);
- if (listener.listen(port) != sf::Socket::Done) {
- std::cout << "Check if port is free" << endl;
- exit(EXIT_FAILURE);
- }
- if (listener.accept(socket) != sf::Socket::Done) {
- std::cout << "Error accepting socket" << endl;
- exit(EXIT_FAILURE);
- }
- while (window.isOpen()) {
- if (socket.getRemotePort() == 0) {
- cout << "Client Disconnected" << endl;
- }
- else {
- cout << "client connected" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement