Added code to throw additional exceptions

master
Aadhavan Srinivasan 11 months ago
parent 2ca17a6225
commit 7c741de587

@ -1,6 +1,6 @@
#include "easysock.hpp"
#include <iostream>
#include <errno.h>
#include <cerrno>
#include "exception_consts.hpp"
/*
Client class - Defines a TCP/UDP client.
@ -44,6 +44,12 @@ public:
this->protocol = protocol;
this->port = port;
this->address = std::string(address);
/* Check to see if the given IP address matches the given ip_ver */
if ((check_ip_ver(address.data() == 4 && ip_ver == 6) || (chcek_ip_ver(address.data() == 6 && address == 4)) {
throw std::invalid_argument("Invalid IP address for given type.");
}
try {
create_socket();
} catch (int e) {

Loading…
Cancel
Save