Hello everyone,
I've been trying to setup a simple UDP server and client but I've got this one issue.
I would like to make it so that the server sends a message back to the client after the server has received a message from that client.
It would go like this.
- Client sends message to server.
- Server receives message. Sends another message back to client.
- Client receives message.
My idea is that the client will send a command to the server for example. Like a request.
The server would then send a packet back to the client containing the requested information.
For example position info.
I might be doing it all wrong and if so. Please feel free to take out the hammer and bash my brains in.
Client (area that is most likely responsible for the issue)
//Listen for connection on port ...
ClientSocket.Bind(0);
char Buffer2[128];
size_t Received;
sf::IPAddress Sender;
unsigned short Port;
//Receive data from server
if(ClientSocket.Receive(Buffer2,sizeof(Buffer2),Received,Sender,Port) == sf::Socket::Done)
{
std::cout<<Buffer2<<std::endl;
}
Client console output
Failed to receive data ; the UDP socket first needs to be bound to a port