Converted applicable enumerations to strongly typed enumerations.

This commit is contained in:
binary1248 2017-04-04 01:13:07 +02:00
parent b3b094fc91
commit 24db1dba1a
74 changed files with 1242 additions and 1251 deletions

View file

@ -17,26 +17,26 @@ void runTcpServer(unsigned short port)
sf::TcpListener listener;
// Listen to the given port for incoming connections
if (listener.listen(port) != sf::Socket::Done)
if (listener.listen(port) != sf::Socket::Status::Done)
return;
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
// Wait for a connection
sf::TcpSocket socket;
if (listener.accept(socket) != sf::Socket::Done)
if (listener.accept(socket) != sf::Socket::Status::Done)
return;
std::cout << "Client connected: " << socket.getRemoteAddress() << std::endl;
// Send a message to the connected client
const char out[] = "Hi, I'm the server";
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
// Receive a message back from the client
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
return;
std::cout << "Answer received from the client: \"" << in << "\"" << std::endl;
}
@ -62,20 +62,20 @@ void runTcpClient(unsigned short port)
sf::TcpSocket socket;
// Connect to the server
if (socket.connect(server, port) != sf::Socket::Done)
if (socket.connect(server, port) != sf::Socket::Status::Done)
return;
std::cout << "Connected to server " << server << std::endl;
// Receive a message from the server
char in[128];
std::size_t received;
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
return;
std::cout << "Message received from the server: \"" << in << "\"" << std::endl;
// Send an answer to the server
const char out[] = "Hi, I'm a client";
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
return;
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
}