Replaced recvAll call with recvAllNB

master
Aadhavan Srinivasan 10 months ago
parent 00d20ebc88
commit ef869710e5

@ -108,7 +108,7 @@ GameType check_server_client(int argc, char** argv) {
client->create_socket();
/* Send a specific message to the server, and wait for the appropriate response, to know that the server is ready */
client->sendAll("GG");
std::string msg_from_server = client->recvAll();
std::string msg_from_server = client->recvAllNB();
if (msg_from_server == "U2") {
std::cout << "Connection made. Waiting for server to begin game..." << std::endl;
} else {
@ -181,7 +181,7 @@ GameType check_server_client(int argc, char** argv) {
int main(int argc, char** argv) {
/* Check if game was started in server or client mode, and set appropriate variables */
/* GameType struct, to define whether the game is in single or muilti-player mode, and
/* GameType struct, to define whether the game is in single or multi-player mode, and
to hold the appropriate socket */
GameType type;
@ -322,9 +322,13 @@ int main(int argc, char** argv) {
type = check_server(ip_text, port_text);
} catch (int e) {
display_and_exit(std::string(std::strerror(e)) + "\nClosing game...", 2); // The server constructor throws the errno if it cannot create a socket
free(ip_text);
free(port_text);
return -1;
} catch (std::invalid_argument& inv) {
display_and_exit(std::string(inv.what()) + "\nClosing game...", 2);
free(ip_text);
free(port_text);
return -1;
}
free(ip_text);
@ -359,6 +363,9 @@ int main(int argc, char** argv) {
} catch (int e) {
display_and_exit(std::string(std::strerror(e)) + "\nClosing game...", 2); // The client constructor throws the errno if it cannot create a socket
return -1;
} catch (std::invalid_argument& inv) {
display_and_exit(std::string(inv.what()) + "\nClosing game...", 2);
return -1;
}
free(code_text);
}

Loading…
Cancel
Save