Hello there! I have been trying to compile the following code in Code::Blocks
#include <iostream>
#include <SFML/Network.hpp>
using namespace sf;
using namespace std;
int main(){
cout << "Would you like to be a server or client? (s/c)" << endl;
char choice;
cin >> choice;
if(choice == 's'){
TcpListener listener;
listener.listen(1337);
std::string message = "";
Packet serverPacket;
while(true){
TcpSocket client;
if(listener.accept(client) == Socket::Done){
cout << "Client has connected from " << client.getRemoteAddress() << endl;
cout << "Send message to client: ";
cin >> message;
serverPacket << message;
client.send(serverPacket);
}
}
}else{
Packet clientPacket;
std::string messageSent;
TcpSocket socket;
if(socket.connect("localhost", 1337)){
cout << "Unable to find server." << endl;
}else{
cout << "Connected to server!" << endl;
}
while(true){
socket.receive(clientPacket);
if(clientPacket >> messageSent){
cout << "[Server] " << messageSent << endl;
}
}
}
return 0;
}
I have followed the tutorial for SFML 2.0 on Windows using Code::Blocks and can run most applications I make fine.
I have only added sfml-graphics-s, sfml-window-s and sfml-system-s and their debugging equivalents to my linker options, am I suppose to add sfml-network-s to make this code compile and run correctly?
The reason I have not tried this myself already is because I'm not sure if sfml-network-s even exists and if it does what order I would add it into the linker options.
Thanks for reading.