From 7ae843039ccc380d423bc887a2b378be83564edd Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sat, 22 Oct 2022 01:18:44 +0200 Subject: [PATCH] tools/hexnet: Implement TCP v6 handler, rename readFromTCPSocket to readFromTCP --- src/tools/hexnet.cpp | 69 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/src/tools/hexnet.cpp b/src/tools/hexnet.cpp index 571a840..ef8324f 100644 --- a/src/tools/hexnet.cpp +++ b/src/tools/hexnet.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -40,6 +42,11 @@ sockpp::tcp_socket tcpSocket; sockpp::tcp_acceptor tcpAcceptor; // TCP v4 client sockpp::tcp_connector tcpConnector; +// TCP v6 server +sockpp::tcp6_socket tcp6Socket; +sockpp::tcp6_acceptor tcp6Acceptor; +// TCP v6 client +sockpp::tcp6_connector tcp6Connector; bool exitProgram = false; @@ -66,7 +73,7 @@ void signalHandler(int signal) { std::exit(EXIT_SIGNAL); } -void readFromTCPSocket() { +void readFromTCP() { ssize_t byteCount; uint8_t buffer[1536]; while (!exitProgram && (outgoing? (byteCount = tcpConnector.read(buffer, sizeof(buffer))) > 0 : (byteCount = tcpSocket.read(buffer, sizeof(buffer))) > 0)) { @@ -77,6 +84,17 @@ void readFromTCPSocket() { } } +void readFromTCP6() { + ssize_t byteCount; + uint8_t buffer[1536]; + while (!exitProgram && (outgoing? (byteCount = tcp6Connector.read(buffer, sizeof(buffer))) > 0 : (byteCount = tcp6Socket.read(buffer, sizeof(buffer))) > 0)) { + for (ssize_t i=0; i