From 79f2c4eb6636fabc032c72e3cca644725a369c0c Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Fri, 15 Sep 2023 14:20:27 +0200 Subject: Added sanity checks for KSocket class. * added deprecation comment for helper.hpp Signed-off-by: Toni Uhlig --- ksocket/ksocket.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ksocket/ksocket.hpp') diff --git a/ksocket/ksocket.hpp b/ksocket/ksocket.hpp index abf03b6..a729d99 100644 --- a/ksocket/ksocket.hpp +++ b/ksocket/ksocket.hpp @@ -6,6 +6,8 @@ #include #include +#define K_IPPROTO_TCP (6) + using KBuffer = eastl::vector; struct KSocketImpl; @@ -16,6 +18,7 @@ enum { KSE_SETUP_INVALID_SOCKET_TYPE = 2, KSE_SETUP_UNSUPPORTED_SOCKET_TYPE = 3, KSE_ACCEPT_FAILED = 4, + KSE_INVALID_SOCKET = 5 }; enum class KSocketType { @@ -41,7 +44,7 @@ struct KSocketAddress { }; class KAcceptedSocket; -using KAcceptThreadCallback = eastl::function; +using KAcceptThreadCallback = eastl::function; struct KSocketBuffer { void insert_i8(KBuffer::iterator it, int8_t value) { @@ -138,6 +141,8 @@ protected: bool send(); bool recv(size_t max_recv_size); + bool sanityCheck(); + public: int getLastError() const { return m_lastError; } @@ -186,8 +191,7 @@ public: ~KStreamClientIp4() {} bool setup() { - return KSocket::setup(KSocketType::KST_STREAM_CLIENT_IP4, - 6 /* IPPROTO_TCP */); + return KSocket::setup(KSocketType::KST_STREAM_CLIENT_IP4, K_IPPROTO_TCP); } bool connect(eastl::string host, eastl::string port) { @@ -211,8 +215,7 @@ public: ~KStreamServerIp4() {} bool setup() { - return KSocket::setup(KSocketType::KST_STREAM_SERVER_IP4, - 6 /* IPPROTO_TCP */); + return KSocket::setup(KSocketType::KST_STREAM_SERVER_IP4, K_IPPROTO_TCP); } bool connect(eastl::string host, eastl::string port) = delete; -- cgit v1.2.3