diff --git a/src/oatpp/core/IODefinitions.hpp b/src/oatpp/core/IODefinitions.hpp index dfb62f5d..26ca9c03 100644 --- a/src/oatpp/core/IODefinitions.hpp +++ b/src/oatpp/core/IODefinitions.hpp @@ -28,6 +28,10 @@ #include "oatpp/core/async/Error.hpp" #include "oatpp/core/Types.hpp" +#if !defined(WIN32) && !defined(_WIN32) +#include +#endif + namespace oatpp { /** @@ -39,9 +43,11 @@ namespace oatpp { #else typedef unsigned long v_io_handle; #endif + typedef int v_sock_size; constexpr const v_io_handle INVALID_IO_HANDLE = v_io_handle (-1); #else typedef int v_io_handle; + typedef socklen_t v_sock_size; constexpr const v_io_handle INVALID_IO_HANDLE = (-1); #endif diff --git a/src/oatpp/network/tcp/client/ConnectionProvider.cpp b/src/oatpp/network/tcp/client/ConnectionProvider.cpp index d84ba7d3..ffef432c 100644 --- a/src/oatpp/network/tcp/client/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/client/ConnectionProvider.cpp @@ -123,7 +123,7 @@ provider::ResourceHandle ConnectionProvider::get() { if(clientHandle >= 0) { - if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { + if(connect(clientHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0) { break; } else { err = errno; @@ -282,7 +282,7 @@ oatpp::async::CoroutineStarterForResultai_addr, static_cast(m_currentResult->ai_addrlen)); + auto res = connect(m_clientHandle, m_currentResult->ai_addr, static_cast(m_currentResult->ai_addrlen)); #if defined(WIN32) || defined(_WIN32) diff --git a/src/oatpp/network/tcp/server/ConnectionProvider.cpp b/src/oatpp/network/tcp/server/ConnectionProvider.cpp index 48f1f888..5b498081 100644 --- a/src/oatpp/network/tcp/server/ConnectionProvider.cpp +++ b/src/oatpp/network/tcp/server/ConnectionProvider.cpp @@ -46,7 +46,7 @@ // Workaround for MinGW from: https://www.mail-archive.com/users@ipv6.org/msg02107.html #if defined(__MINGW32__) && _WIN32_WINNT < 0x0600 - const char * inet_ntop (int af, const void *src, char *dst, socklen_t cnt) { + const char * inet_ntop (int af, const void *src, char *dst, oatpp::v_sock_size cnt) { if (af == AF_INET) { struct sockaddr_in in; @@ -228,7 +228,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ // Update port after binding (typicaly in case of port = 0) struct ::sockaddr_in s_in; ::memset(&s_in, 0, sizeof(s_in)); - ::socklen_t s_in_len = sizeof(s_in); + oatpp::v_sock_size s_in_len = sizeof(s_in); ::getsockname(serverHandle, (struct sockaddr *)&s_in, &s_in_len); setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port))); @@ -280,7 +280,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ "Warning. Failed to set %s for accepting socket: %s", "SO_REUSEADDR", strerror(errno)) } - if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && + if (bind(serverHandle, currResult->ai_addr, static_cast(currResult->ai_addrlen)) == 0 && listen(serverHandle, 10000) == 0) { break; @@ -309,7 +309,7 @@ oatpp::v_io_handle ConnectionProvider::instantiateServer(){ // Update port after binding (typicaly in case of port = 0) ::sockaddr_in s_in; ::memset(&s_in, 0, sizeof(s_in)); - ::socklen_t s_in_len = sizeof(s_in); + oatpp::v_sock_size s_in_len = sizeof(s_in);//FIXME trace ::getsockname(serverHandle, reinterpret_cast(&s_in), &s_in_len); setProperty(PROPERTY_PORT, oatpp::utils::conversion::int32ToStr(ntohs(s_in.sin_port))); @@ -351,7 +351,7 @@ provider::ResourceHandle ConnectionProvider::getDefaultC provider::ResourceHandle ConnectionProvider::getExtendedConnection() { sockaddr_storage clientAddress; - socklen_t clientAddressSize = sizeof(clientAddress); + v_sock_size clientAddressSize = sizeof(clientAddress); data::stream::Context::Properties properties; diff --git a/src/oatpp/parser/json/mapping/Deserializer.cpp b/src/oatpp/parser/json/mapping/Deserializer.cpp index 4c44fe6e..180625c3 100644 --- a/src/oatpp/parser/json/mapping/Deserializer.cpp +++ b/src/oatpp/parser/json/mapping/Deserializer.cpp @@ -494,7 +494,7 @@ oatpp::Void Deserializer::deserializeObject(Deserializer* deserializer, parser:: } oatpp::Void Deserializer::deserialize(parser::Caret& caret, const Type* const type) { - v_uint32 id = static_cast(type->classId.id); + auto id = static_cast(type->classId.id); auto& method = m_methods[id]; if(method) { return (*method)(this, caret, type); diff --git a/src/oatpp/parser/json/mapping/Serializer.cpp b/src/oatpp/parser/json/mapping/Serializer.cpp index a4e638af..c0df709c 100644 --- a/src/oatpp/parser/json/mapping/Serializer.cpp +++ b/src/oatpp/parser/json/mapping/Serializer.cpp @@ -259,7 +259,7 @@ void Serializer::serializeObject(Serializer* serializer, void Serializer::serialize(data::stream::ConsistentOutputStream* stream, const oatpp::Void& polymorph) { - v_uint32 id = static_cast(polymorph.getValueType()->classId.id); + auto id = static_cast(polymorph.getValueType()->classId.id); auto& method = m_methods[id]; if(method) { (*method)(this, stream, polymorph);