In the first all is well, but in the second it stops sending. Must I always send and receive, even if it is an empty socket?
bool client(){
const char out[] = "Hi, I'm a client";
if (socket.send(out, sizeof(out), server, PORT) != sf::Socket::Done)
return false;
char in[128];
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in) , received, sender, senderPort) != sf::Socket::Done)
return false;
}
void server(){
char in[128];
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
return false;
const char out[] = "";
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
return false;
}
Second:
bool client(){
const char out[] = "Hi, I'm a client";
if (socket.send(out, sizeof(out), server, PORT) != sf::Socket::Done)
return false;
char in[128];
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in) , received, sender, senderPort) != sf::Socket::Done)
return false;
}
void server(){
char in[128];
std::size_t received;
sf::IpAddress sender;
unsigned short senderPort;
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
return false;
/*
const char out[] = "";
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
return false;
*/
}