Updated Server and Client constructor calls, so that they don't pass in the IP version
This commit is contained in:
15
main.cpp
15
main.cpp
@@ -99,7 +99,18 @@ GameType check_server_client(int argc, char** argv) {
|
||||
connect_code = std::string(argv[2]); /* The connect code is a special string, that contains the server address and port. It is given by the server. */
|
||||
try {
|
||||
addr_port = connect_code::decode(connect_code);
|
||||
Client* client = new Client(4, ES_UDP, addr_port[0].data(), std::stoi(addr_port[1]));
|
||||
/* Check IP address version */
|
||||
int ip_ver = 0;
|
||||
if (check_ip_ver(addr_port[0].data()) < 0) {
|
||||
throw std::invalid_argument("Invalid code entered.");
|
||||
}
|
||||
/* From here, assume address is either IPv4 or IPv6 */
|
||||
if (check_ip_ver(addr_port[0].data()) == 4) {
|
||||
ip_ver = 4;
|
||||
} else {
|
||||
ip_ver = 6;
|
||||
}
|
||||
Client* client = new Client(ES_UDP, addr_port[0].data(), std::stoi(addr_port[1]));
|
||||
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");
|
||||
@@ -148,7 +159,7 @@ GameType check_server_client(int argc, char** argv) {
|
||||
std::cout << "Your code is " << code << std::endl;
|
||||
|
||||
/* Create server socket and wait for client to connect */
|
||||
Server* server = new Server(4, ES_UDP, addr.data(), port);
|
||||
Server* server = new Server(ES_UDP, addr.data(), port);
|
||||
server->create_socket();
|
||||
std::cout << "Waiting for connection..." << std::endl;
|
||||
std::string response = "";
|
||||
|
Reference in New Issue
Block a user