now working with libuv v1.27.x (close #148)

This commit is contained in:
Michele Caini 2019-03-20 17:31:44 +01:00
parent 8349a74801
commit 6f5c43ae8e
4 changed files with 79 additions and 3 deletions

View File

@ -16,7 +16,7 @@ endif()
# Project configuration
#
project(uvw VERSION 1.14.2)
project(uvw VERSION 1.15.0)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)

View File

@ -17,7 +17,7 @@ ExternalProject_Add(
ExternalProject_Add(
libuv
GIT_REPOSITORY https://github.com/libuv/libuv.git
GIT_TAG v1.26.0
GIT_TAG v1.27.0
SOURCE_DIR @LIBUV_DEPS_DIR@
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -14,7 +14,7 @@ class UVMConan(ConanFile):
exports = "LICENSE"
exports_sources = "src/*"
no_copy_source = True
requires = "libuv/1.26.0@bincrafters/stable"
requires = "libuv/1.27.0@bincrafters/stable"
def package(self):
self.copy(pattern="LICENSE", dst="licenses")

View File

@ -176,6 +176,82 @@ public:
invoke(&uv_udp_bind, get(), &addr, opts);
}
/**
* @brief Associates the handle to a remote address and port (either IPv4 or
* IPv6).
*
* Every message sent by this handle is automatically sent to the given
* destination.<br/>
* Trying to call this function on an already connected handle isn't
* allowed.
*
* An ErrorEvent event is emitted in case of errors during the connection.
*
* @param addr Initialized `sockaddr_in` or `sockaddr_in6` data structure.
*/
void connect(const sockaddr &addr) {
invoke(&uv_udp_connect, get(), &addr);
}
/**
* @brief Associates the handle to a remote address and port (either IPv4 or
* IPv6).
*
* Every message sent by this handle is automatically sent to the given
* destination.<br/>
* Trying to call this function on an already connected handle isn't
* allowed.
*
* An ErrorEvent event is emitted in case of errors during the connection.
*
* @param ip The address to which to bind.
* @param port The port to which to bind.
*/
template<typename I = IPv4>
void connect(std::string ip, unsigned int port) {
typename details::IpTraits<I>::Type addr;
details::IpTraits<I>::addrFunc(ip.data(), port, &addr);
connect(reinterpret_cast<const sockaddr &>(addr));
}
/**
* @brief Associates the handle to a remote address and port (either IPv4 or
* IPv6).
*
* Every message sent by this handle is automatically sent to the given
* destination.<br/>
* Trying to call this function on an already connected handle isn't
* allowed.
*
* An ErrorEvent event is emitted in case of errors during the connection.
*
* @param addr A valid instance of Addr.
*/
template<typename I = IPv4>
void connect(Addr addr) {
connect<I>(std::move(addr.ip), addr.port);
}
/**
* @brief Disconnects the handle.
*
* Trying to disconnect a handle that is not connected isn't allowed.
*
* An ErrorEvent event is emitted in case of errors.
*/
void disconnect() {
invoke(&uv_udp_connect, get(), nullptr);
}
/**
* @brief Gets the remote address to which the handle is connected, if any.
* @return A valid instance of Addr, an empty one in case of errors.
*/
template<typename I = IPv4>
Addr peer() const noexcept {
return details::address<I>(&uv_udp_getpeername, get());
}
/**
* @brief Binds the UDP handle to an IP address and port.
*