This commit is contained in:
Michele Caini 2018-11-06 14:34:49 +01:00
parent 88d718d490
commit a9bad602df
10 changed files with 98 additions and 98 deletions

View File

@ -30,13 +30,13 @@ As an example, a *handle* should be initialized before any other operation and c
#include <memory>
void listen(uvw::Loop &loop) {
std::shared_ptr<uvw::TcpHandle> tcp = loop.resource<uvw::TcpHandle>();
std::shared_ptr<uvw::TCPHandle> tcp = loop.resource<uvw::TCPHandle>();
tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &srv) {
std::shared_ptr<uvw::TcpHandle> client = srv.loop().resource<uvw::TcpHandle>();
tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &srv) {
std::shared_ptr<uvw::TCPHandle> client = srv.loop().resource<uvw::TCPHandle>();
client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TcpHandle &) { ptr->close(); });
client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &client) { client.close(); });
client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TCPHandle &) { ptr->close(); });
client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &client) { client.close(); });
srv.accept(*client);
client->read();
@ -47,11 +47,11 @@ void listen(uvw::Loop &loop) {
}
void conn(uvw::Loop &loop) {
auto tcp = loop.resource<uvw::TcpHandle>();
auto tcp = loop.resource<uvw::TCPHandle>();
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { /* handle errors */ });
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { /* handle errors */ });
tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TcpHandle &tcp) {
tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TCPHandle &tcp) {
auto dataWrite = std::unique_ptr<char[]>(new char[2]{ 'b', 'c' });
tcp.write(std::move(dataWrite), 2);
tcp.close();
@ -202,7 +202,7 @@ Available modes are: `DEFAULT`, `ONCE`, `NOWAIT`. Please refer to the documentat
In order to create a resource and to bind it to the given loop, just do the following:
```cpp
auto tcp = loop.resource<uvw::TcpHandle>();
auto tcp = loop.resource<uvw::TCPHandle>();
```
The line above will create and initialize a tcp handle, then a shared pointer to that resource will be returned.<br/>
@ -210,7 +210,7 @@ Users should check if pointers have been correctly initialized: in case of error
Another way to create a resource is:
```cpp
auto tcp = TcpHandle::create(loop);
auto tcp = TCPHandle::create(loop);
tcp->init();
```
@ -272,7 +272,7 @@ There exist two methods to attach an event to a resource:
* `resource.once<EventType>(listener)`: the listener will be automatically removed after the first event of the given type.
* `resource.on<EventType>(listener)`: to be used for long-running listeners.
Both of them return an object of type `ResourceType::Connection` (as an example, `TcpHandle::Connection`).<br/>
Both of them return an object of type `ResourceType::Connection` (as an example, `TCPHandle::Connection`).<br/>
A connection object can be used later as an argument to the `erase` member function of the resource to remove the listener.<br/>
There exists also the `clear` member function to drop all the listeners at once.
@ -283,14 +283,14 @@ The code below shows how to create a simple tcp server using `uvw`:
```cpp
auto loop = uvw::Loop::getDefault();
auto tcp = loop.resource<uvw::TcpHandle>();
auto tcp = loop.resource<uvw::TCPHandle>();
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { /* something went wrong */ });
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { /* something went wrong */ });
tcp->on<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &srv) {
std::shared_ptr<uvw::TcpHandle> client = srv.loop().resource<uvw::TcpHandle>();
client->once<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &client) { client.close(); });
client->on<uvw::DataEvent>([](const uvw::DataEvent &, uvw::TcpHandle &) { /* data received */ });
tcp->on<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &srv) {
std::shared_ptr<uvw::TCPHandle> client = srv.loop().resource<uvw::TCPHandle>();
client->once<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &client) { client.close(); });
client->on<uvw::DataEvent>([](const uvw::DataEvent &, uvw::TCPHandle &) { /* data received */ });
srv.accept(*client);
client->read();
});
@ -299,7 +299,7 @@ tcp->bind("127.0.0.1", 4242);
tcp->listen();
```
Note also that `uvw::TcpHandle` already supports _IPv6_ out-of-the-box. The statement above is equivalent to `tcp->bind<uvw::IPv4>("127.0.0.1", 4242)`.<br/>
Note also that `uvw::TCPHandle` already supports _IPv6_ out-of-the-box. The statement above is equivalent to `tcp->bind<uvw::IPv4>("127.0.0.1", 4242)`.<br/>
It's suffice to explicitly specify `uvw::IPv6` as the underlying protocol to use it.
The API reference is the recommended documentation for further details about resources and their methods.
@ -319,7 +319,7 @@ That being said, _going raw_ is a matter of using the `raw` member functions:
```cpp
auto loop = uvw::Loop::getDefault();
auto tcp = loop.resource<uvw::TcpHandle>();
auto tcp = loop.resource<uvw::TCPHandle>();
uv_loop_t *raw = loop->raw();
uv_tcp_t *handle = tcp->raw();

View File

@ -99,7 +99,7 @@ public:
*
* * An AsyncHandle handle is always active and cannot be deactivated,
* except by closing it with uv_close().
* * A PipeHandle, TcpHandle, UDPHandle, etc. handle - basically any handle
* * A PipeHandle, TCPHandle, UDPHandle, etc. handle - basically any handle
* that deals with I/O - is active when it is doing something that involves
* I/O, like reading, writing, connecting, accepting new connections, etc.
* * A CheckHandle, IdleHandle, TimerHandle, etc. handle is active when it
@ -183,8 +183,8 @@ public:
*
* Gets the size of the send buffer that the operating system uses for the
* socket.<br/>
* This function works for TcpHandle, PipeHandle and UDPHandle handles on
* Unix and for TcpHandle and UDPHandle handles on Windows.<br/>
* This function works for TCPHandle, PipeHandle and UDPHandle handles on
* Unix and for TCPHandle and UDPHandle handles on Windows.<br/>
* Note that Linux will return double the size of the original set value.
*
* @return The size of the send buffer, 0 in case of errors.
@ -200,8 +200,8 @@ public:
*
* Sets the size of the send buffer that the operating system uses for the
* socket.<br/>
* This function works for TcpHandle, PipeHandle and UDPHandle handles on
* Unix and for TcpHandle and UDPHandle handles on Windows.<br/>
* This function works for TCPHandle, PipeHandle and UDPHandle handles on
* Unix and for TCPHandle and UDPHandle handles on Windows.<br/>
* Note that Linux will set double the size.
*
* @return True in case of success, false otherwise.
@ -215,8 +215,8 @@ public:
*
* Gets the size of the receive buffer that the operating system uses for
* the socket.<br/>
* This function works for TcpHandle, PipeHandle and UDPHandle handles on
* Unix and for TcpHandle and UDPHandle handles on Windows.<br/>
* This function works for TCPHandle, PipeHandle and UDPHandle handles on
* Unix and for TCPHandle and UDPHandle handles on Windows.<br/>
* Note that Linux will return double the size of the original set value.
*
* @return The size of the receive buffer, 0 in case of errors.
@ -232,8 +232,8 @@ public:
*
* Sets the size of the receive buffer that the operating system uses for
* the socket.<br/>
* This function works for TcpHandle, PipeHandle and UDPHandle handles on
* Unix and for TcpHandle and UDPHandle handles on Windows.<br/>
* This function works for TCPHandle, PipeHandle and UDPHandle handles on
* Unix and for TCPHandle and UDPHandle handles on Windows.<br/>
* Note that Linux will set double the size.
*
* @return True in case of success, false otherwise.
@ -247,7 +247,7 @@ public:
*
* Supported handles:
*
* * TcpHandle
* * TCPHandle
* * PipeHandle
* * TTYHandle
* * UDPHandle

View File

@ -74,7 +74,7 @@ struct BaseHandle {
*
* * An AsyncHandle handle is always active and cannot be deactivated,
* except by closing it with uv_close().
* * A PipeHandle, TcpHandle, UDPHandle, etc. handle - basically any handle
* * A PipeHandle, TCPHandle, UDPHandle, etc. handle - basically any handle
* that deals with I/O - is active when it is doing something that involves
* I/O, like reading, writing, connecting, accepting new connections, etc.
* * A CheckHandle, IdleHandle, TimerHandle, etc. handle is active when it

View File

@ -124,7 +124,7 @@ private:
*
* Stream handles provide an abstraction of a duplex communication channel.
* StreamHandle is an intermediate type, `uvw` provides three stream
* implementations: TcpHandle, PipeHandle and TTYHandle.
* implementations: TCPHandle, PipeHandle and TTYHandle.
*/
template<typename T, typename U>
class StreamHandle: public Handle<T, U> {
@ -301,7 +301,7 @@ public:
*
* The pipe must be initialized with `ipc == true`.
*
* `send` must be a TcpHandle or PipeHandle handle, which is a server or a
* `send` must be a TCPHandle or PipeHandle handle, which is a server or a
* connection (listening or connected state). Bound sockets or pipes will be
* assumed to be servers.
*
@ -336,7 +336,7 @@ public:
*
* The pipe must be initialized with `ipc == true`.
*
* `send` must be a TcpHandle or PipeHandle handle, which is a server or a
* `send` must be a TCPHandle or PipeHandle handle, which is a server or a
* connection (listening or connected state). Bound sockets or pipes will be
* assumed to be servers.
*

View File

@ -18,7 +18,7 @@ namespace uvw {
namespace details {
enum class UVTcpFlags: std::underlying_type_t<uv_tcp_flags> {
enum class UVTCPFlags: std::underlying_type_t<uv_tcp_flags> {
IPV6ONLY = UV_TCP_IPV6ONLY
};
@ -27,13 +27,13 @@ enum class UVTcpFlags: std::underlying_type_t<uv_tcp_flags> {
/**
* @brief The TcpHandle handle.
* @brief The TCPHandle handle.
*
* TCP handles are used to represent both TCP streams and servers.<br/>
* By default, _IPv4_ is used as a template parameter. The handle already
* supports _IPv6_ out-of-the-box by using `uvw::IPv6`.
*
* To create a `TcpHandle` through a `Loop`, arguments follow:
* To create a `TCPHandle` through a `Loop`, arguments follow:
*
* * An optional integer value that indicates the flags used to initialize
* the socket.
@ -42,14 +42,14 @@ enum class UVTcpFlags: std::underlying_type_t<uv_tcp_flags> {
* [documentation](http://docs.libuv.org/en/v1.x/tcp.html#c.uv_tcp_init_ex)
* for further details.
*/
class TcpHandle final: public StreamHandle<TcpHandle, uv_tcp_t> {
class TCPHandle final: public StreamHandle<TCPHandle, uv_tcp_t> {
public:
using Time = std::chrono::duration<unsigned int>;
using Bind = details::UVTcpFlags;
using Bind = details::UVTCPFlags;
using IPv4 = uvw::IPv4;
using IPv6 = uvw::IPv6;
explicit TcpHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, unsigned int f = {})
explicit TCPHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref, unsigned int f = {})
: StreamHandle{ca, std::move(ref)}, tag{f ? FLAGS : DEFAULT}, flags{f}
{}
@ -123,7 +123,7 @@ public:
*
* Available flags are:
*
* * `TcpHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* * `TCPHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* IPv6 is used.
*
* @param addr Initialized `sockaddr_in` or `sockaddr_in6` data structure.
@ -143,7 +143,7 @@ public:
*
* Available flags are:
*
* * `TcpHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* * `TCPHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* IPv6 is used.
*
* @param ip The address to which to bind.
@ -167,7 +167,7 @@ public:
*
* Available flags are:
*
* * `TcpHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* * `TCPHandle::Bind::IPV6ONLY`: it disables dual-stack support and only
* IPv6 is used.
*
* @param addr A valid instance of Addr.

View File

@ -45,7 +45,7 @@ struct UDPDataEvent {
namespace details {
enum class UVUdpFlags: std::underlying_type_t<uv_udp_flags> {
enum class UVUDPFlags: std::underlying_type_t<uv_udp_flags> {
IPV6ONLY = UV_UDP_IPV6ONLY,
REUSEADDR = UV_UDP_REUSEADDR
};
@ -121,7 +121,7 @@ class UDPHandle final: public Handle<UDPHandle, uv_udp_t> {
public:
using Membership = details::UVMembership;
using Bind = details::UVUdpFlags;
using Bind = details::UVUDPFlags;
using IPv4 = uvw::IPv4;
using IPv6 = uvw::IPv6;

View File

@ -6,22 +6,22 @@
void listen(uvw::Loop &loop) {
std::shared_ptr<uvw::TcpHandle> tcp = loop.resource<uvw::TcpHandle>();
std::shared_ptr<uvw::TCPHandle> tcp = loop.resource<uvw::TCPHandle>();
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) {
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) {
std::cout << "error " << std::endl;
});
tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &srv) {
tcp->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &srv) {
std::cout << "listen" << std::endl;
std::shared_ptr<uvw::TcpHandle> client = srv.loop().resource<uvw::TcpHandle>();
std::shared_ptr<uvw::TCPHandle> client = srv.loop().resource<uvw::TCPHandle>();
client->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) {
client->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) {
std::cout << "error " << std::endl;
});
client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TcpHandle &) {
client->on<uvw::CloseEvent>([ptr = srv.shared_from_this()](const uvw::CloseEvent &, uvw::TCPHandle &) {
std::cout << "close" << std::endl;
ptr->close();
});
@ -34,12 +34,12 @@ void listen(uvw::Loop &loop) {
uvw::Addr remote = client->peer();
std::cout << "remote: " << remote.ip << " " << remote.port << std::endl;
client->on<uvw::DataEvent>([](const uvw::DataEvent &event, uvw::TcpHandle &) {
client->on<uvw::DataEvent>([](const uvw::DataEvent &event, uvw::TCPHandle &) {
std::cout.write(event.data.get(), event.length) << std::endl;
std::cout << "data length: " << event.length << std::endl;
});
client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &handle) {
client->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &handle) {
std::cout << "end" << std::endl;
int count = 0;
handle.loop().walk([&count](uvw::BaseHandle &) { ++count; });
@ -50,7 +50,7 @@ void listen(uvw::Loop &loop) {
client->read();
});
tcp->once<uvw::CloseEvent>([](const uvw::CloseEvent &, uvw::TcpHandle &) {
tcp->once<uvw::CloseEvent>([](const uvw::CloseEvent &, uvw::TCPHandle &) {
std::cout << "close" << std::endl;
});
@ -60,18 +60,18 @@ void listen(uvw::Loop &loop) {
void conn(uvw::Loop &loop) {
auto tcp = loop.resource<uvw::TcpHandle>();
auto tcp = loop.resource<uvw::TCPHandle>();
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) {
tcp->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) {
std::cout << "error " << std::endl;
});
tcp->once<uvw::WriteEvent>([](const uvw::WriteEvent &, uvw::TcpHandle &handle) {
tcp->once<uvw::WriteEvent>([](const uvw::WriteEvent &, uvw::TCPHandle &handle) {
std::cout << "write" << std::endl;
handle.close();
});
tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TcpHandle &handle) {
tcp->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TCPHandle &handle) {
std::cout << "connect" << std::endl;
auto dataTryWrite = std::unique_ptr<char[]>(new char[1]{ 'a' });
@ -82,7 +82,7 @@ void conn(uvw::Loop &loop) {
handle.write(std::move(dataWrite), 2);
});
tcp->once<uvw::CloseEvent>([](const uvw::CloseEvent &, uvw::TcpHandle &) {
tcp->once<uvw::CloseEvent>([](const uvw::CloseEvent &, uvw::TCPHandle &) {
std::cout << "close" << std::endl;
});

View File

@ -2,12 +2,12 @@
#include <uvw.hpp>
TEST(Tcp, Functionalities) {
TEST(TCP, Functionalities) {
auto loop = uvw::Loop::getDefault();
auto handle = loop->resource<uvw::TcpHandle>();
auto handle = loop->resource<uvw::TCPHandle>();
ASSERT_TRUE(handle->noDelay(true));
ASSERT_TRUE(handle->keepAlive(true, uvw::TcpHandle::Time{128}));
ASSERT_TRUE(handle->keepAlive(true, uvw::TCPHandle::Time{128}));
ASSERT_TRUE(handle->simultaneousAccepts());
handle->close();
@ -15,33 +15,33 @@ TEST(Tcp, Functionalities) {
}
TEST(Tcp, ReadWrite) {
TEST(TCP, ReadWrite) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
auto loop = uvw::Loop::getDefault();
auto server = loop->resource<uvw::TcpHandle>();
auto client = loop->resource<uvw::TcpHandle>();
auto server = loop->resource<uvw::TCPHandle>();
auto client = loop->resource<uvw::TCPHandle>();
server->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
client->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
server->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &handle) {
std::shared_ptr<uvw::TcpHandle> socket = handle.loop().resource<uvw::TcpHandle>();
server->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &handle) {
std::shared_ptr<uvw::TCPHandle> socket = handle.loop().resource<uvw::TCPHandle>();
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TcpHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &sock) { sock.close(); });
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TCPHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &sock) { sock.close(); });
handle.accept(*socket);
socket->read();
});
client->once<uvw::WriteEvent>([](const uvw::WriteEvent &, uvw::TcpHandle &handle) {
client->once<uvw::WriteEvent>([](const uvw::WriteEvent &, uvw::TCPHandle &handle) {
handle.close();
});
client->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TcpHandle &handle) {
client->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TCPHandle &handle) {
ASSERT_TRUE(handle.writable());
ASSERT_TRUE(handle.readable());
@ -59,23 +59,23 @@ TEST(Tcp, ReadWrite) {
}
TEST(Tcp, SockPeer) {
TEST(TCP, SockPeer) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
auto loop = uvw::Loop::getDefault();
auto server = loop->resource<uvw::TcpHandle>();
auto client = loop->resource<uvw::TcpHandle>();
auto server = loop->resource<uvw::TCPHandle>();
auto client = loop->resource<uvw::TCPHandle>();
server->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
client->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
server->once<uvw::ListenEvent>([&address, port](const uvw::ListenEvent &, uvw::TcpHandle &handle) {
std::shared_ptr<uvw::TcpHandle> socket = handle.loop().resource<uvw::TcpHandle>();
server->once<uvw::ListenEvent>([&address, port](const uvw::ListenEvent &, uvw::TCPHandle &handle) {
std::shared_ptr<uvw::TCPHandle> socket = handle.loop().resource<uvw::TCPHandle>();
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TcpHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &sock) { sock.close(); });
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TCPHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &sock) { sock.close(); });
handle.accept(*socket);
socket->read();
@ -86,7 +86,7 @@ TEST(Tcp, SockPeer) {
ASSERT_EQ(addr.port, decltype(addr.port){port});
});
client->once<uvw::ConnectEvent>([&address](const uvw::ConnectEvent &, uvw::TcpHandle &handle) {
client->once<uvw::ConnectEvent>([&address](const uvw::ConnectEvent &, uvw::TCPHandle &handle) {
uvw::Addr addr = handle.peer();
ASSERT_EQ(addr.ip, address);
@ -103,33 +103,33 @@ TEST(Tcp, SockPeer) {
}
TEST(Tcp, Shutdown) {
TEST(TCP, Shutdown) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
auto loop = uvw::Loop::getDefault();
auto server = loop->resource<uvw::TcpHandle>();
auto client = loop->resource<uvw::TcpHandle>();
auto server = loop->resource<uvw::TCPHandle>();
auto client = loop->resource<uvw::TCPHandle>();
server->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
client->on<uvw::ErrorEvent>([](const auto &, auto &) { FAIL(); });
server->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TcpHandle &handle) {
std::shared_ptr<uvw::TcpHandle> socket = handle.loop().resource<uvw::TcpHandle>();
server->once<uvw::ListenEvent>([](const uvw::ListenEvent &, uvw::TCPHandle &handle) {
std::shared_ptr<uvw::TCPHandle> socket = handle.loop().resource<uvw::TCPHandle>();
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TcpHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TcpHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TcpHandle &sock) { sock.close(); });
socket->on<uvw::ErrorEvent>([](const uvw::ErrorEvent &, uvw::TCPHandle &) { FAIL(); });
socket->on<uvw::CloseEvent>([&handle](const uvw::CloseEvent &, uvw::TCPHandle &) { handle.close(); });
socket->on<uvw::EndEvent>([](const uvw::EndEvent &, uvw::TCPHandle &sock) { sock.close(); });
handle.accept(*socket);
socket->read();
});
client->once<uvw::ShutdownEvent>([](const uvw::ShutdownEvent &, uvw::TcpHandle &handle) {
client->once<uvw::ShutdownEvent>([](const uvw::ShutdownEvent &, uvw::TCPHandle &handle) {
handle.close();
});
client->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TcpHandle &handle) {
client->once<uvw::ConnectEvent>([](const uvw::ConnectEvent &, uvw::TCPHandle &handle) {
handle.shutdown();
});
@ -141,9 +141,9 @@ TEST(Tcp, Shutdown) {
}
TEST(Tcp, WriteError) {
TEST(TCP, WriteError) {
auto loop = uvw::Loop::getDefault();
auto handle = loop->resource<uvw::TcpHandle>();
auto handle = loop->resource<uvw::TCPHandle>();
bool checkWriteSmartPtrErrorEvent = false;
bool checkWriteNakedPtrErrorEvent = false;

View File

@ -2,7 +2,7 @@
#include <uvw.hpp>
TEST(Udp, Functionalities) {
TEST(UDP, Functionalities) {
auto loop = uvw::Loop::getDefault();
auto handle = loop->resource<uvw::UDPHandle>();
@ -21,7 +21,7 @@ TEST(Udp, Functionalities) {
}
TEST(Udp, BindRecvStop) {
TEST(UDP, BindRecvStop) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
@ -39,7 +39,7 @@ TEST(Udp, BindRecvStop) {
}
TEST(Udp, ReadTrySend) {
TEST(UDP, ReadTrySend) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
@ -70,7 +70,7 @@ TEST(Udp, ReadTrySend) {
}
TEST(Udp, ReadSend) {
TEST(UDP, ReadSend) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;
@ -104,7 +104,7 @@ TEST(Udp, ReadSend) {
}
TEST(Udp, Sock) {
TEST(UDP, Sock) {
const std::string address = std::string{"127.0.0.1"};
const unsigned int port = 4242;

View File

@ -113,7 +113,7 @@ TEST(Util, Utilities) {
guessHandle(tag<uvw::IdleHandle>{}, uvw::HandleType::IDLE);
guessHandle(tag<uvw::PipeHandle>{}, uvw::HandleType::PIPE);
guessHandle(tag<uvw::PrepareHandle>{}, uvw::HandleType::PREPARE);
guessHandle(tag<uvw::TcpHandle>{}, uvw::HandleType::TCP);
guessHandle(tag<uvw::TCPHandle>{}, uvw::HandleType::TCP);
guessHandle(tag<uvw::TimerHandle>{}, uvw::HandleType::TIMER);
guessHandle(tag<uvw::UDPHandle>{}, uvw::HandleType::UDP);
guessHandle(tag<uvw::SignalHandle>{}, uvw::HandleType::SIGNAL);