The expected behavior is for the client to send a packet containing an ID, x, and y value and for the server to receive the packet and print out the x and y. At the moment, the client just can't send anything.
Here is the code i think is relevant.
In the main of the client code
1 2 3 4 5 6 7 8 9
//Send the position to the server
if(clock.getElapsedTime() > sf::milliseconds(30))
{
clock.restart();
packet.clear();
packet << ID << ball._position.x << ball._position.y;
if( socket.send(packet, serverAddress, 55002) != sf::Socket::Done)
std::cout<<"Error sending packet" << std::endl;
}
Could the problem be that the client and server are not being timed right? The client sends every 30 milliseconds and the server receives every 10 milleseconds and the dont start at the same time.. so is it possible that they are never lined up correctly? I am new to networking and not sure how to solve this problem.
Also, sometimes the client is able to send one message, but cannot successfully send any after that.