From 7c741de587b6d02534b56cfe99f6c345d0c7b9ec Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 6 Feb 2024 07:49:54 -0500 Subject: [PATCH] Added code to throw additional exceptions --- includes/client.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/client.hpp b/includes/client.hpp index 80062e0..37f24e7 100644 --- a/includes/client.hpp +++ b/includes/client.hpp @@ -1,6 +1,6 @@ #include "easysock.hpp" #include -#include +#include #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) {