diff --git a/net/include/ftl/net/socket.hpp b/net/include/ftl/net/socket.hpp index 96786e4fb6d4e45a5519a7321cee16328b185eaf..6b0fc7a31b994ef2d0d6d2f63433988d081871f2 100644 --- a/net/include/ftl/net/socket.hpp +++ b/net/include/ftl/net/socket.hpp @@ -39,6 +39,8 @@ struct caller : virtual_caller { std::function<void(const T&)> f_; }; +typedef std::tuple<const char*,size_t> array; + /** * A single socket connection object, to be constructed using the connect() * function and not to be created directly. @@ -140,8 +142,8 @@ class Socket { template <typename... ARGS> int _send(const std::string &t, ARGS... args); - template <typename T, typename... ARGS> - int _send(const T *t, int s, ARGS... args); + template <typename... ARGS> + int _send(const array &b, ARGS... args); template <typename T, typename... ARGS> int _send(const std::vector<T> &t, ARGS... args); @@ -228,11 +230,11 @@ int Socket::_send(const std::string &t, ARGS... args) { return t.size()+_send(args...); } -template <typename T, typename... ARGS> -int Socket::_send(const T *t, int s, ARGS... args) { - send_vec_.push_back({const_cast<char*>(t),(size_t)s}); - header_w_->size += s; - return s+_send(args...); +template <typename... ARGS> +int Socket::_send(const ftl::net::array &b, ARGS... args) { + send_vec_.push_back({const_cast<char*>(std::get<0>(b)),std::get<1>(b)}); + header_w_->size += std::get<1>(b); + return std::get<1>(b)+_send(args...); } template <typename T, typename... ARGS> diff --git a/net/src/listener.cpp b/net/src/listener.cpp index 6fd975d1b1ef82e850d029c17d2ee16d2733ea1b..0338db14abc3f089cf948eacfa440e58d6dc4ea1 100644 --- a/net/src/listener.cpp +++ b/net/src/listener.cpp @@ -83,6 +83,8 @@ int tcpListen(URI &uri) { return INVALID_SOCKET; } + LOG(INFO) << "Listening on " << uri.getBaseURI(); + return ssock; } diff --git a/net/test/socket_unit.cpp b/net/test/socket_unit.cpp index 19cd3a0d449fe6ff2a83665a0e236779c125c169..a71bdac2b677735c1322cbc09e8e331c48b527e6 100644 --- a/net/test/socket_unit.cpp +++ b/net/test/socket_unit.cpp @@ -248,7 +248,7 @@ TEST_CASE("Socket::send()", "[io]") { } SECTION("send const char* array") { - s.send(100,"hello world",10); + s.send(100,ftl::net::array{"hello world",10}); REQUIRE( get_service(0) == 100 ); REQUIRE( get_size(0) == 10 );