Added code to throw additional exceptions
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user