uvco 0.1
Loading...
Searching...
No Matches
tcp_stream.h
Go to the documentation of this file.
1// uvco (c) 2023 Lewin Bormann. See LICENSE for specific terms.
2
3#pragma once
4
5#include <uv.h>
6
7#include <boost/assert.hpp>
8#include <fmt/format.h>
9
11#include "uvco/stream.h"
12
13#include <memory>
14#include <sys/socket.h>
15#include <utility>
16
17namespace uvco {
18
22class TcpStream : public StreamBase {
23public:
24 explicit TcpStream(std::unique_ptr<uv_tcp_t> tcp)
25 : StreamBase{std::move(tcp)} {}
26 TcpStream(const TcpStream &) = delete;
27 TcpStream(TcpStream &&) = default;
28 TcpStream &operator=(const TcpStream &) = delete;
30 ~TcpStream() override = default;
31
33 [[nodiscard]] AddressHandle getPeerName() const;
34
36 [[nodiscard]] AddressHandle getSockName() const;
37
39 void keepAlive(bool enable, unsigned int delay = 10);
40
42 void noDelay(bool enable);
43};
44
45} // namespace uvco
AddressHandle is a light-weight wrapper around a struct / sockaddr_in(6), and is therefore cheap to c...
Definition name_resolution.h:32
StreamBase(std::unique_ptr< Stream > stream)
Definition stream.h:37
AddressHandle getSockName() const
Return bound address of socket.
Definition tcp_stream.cc:15
void keepAlive(bool enable, unsigned int delay=10)
Set keep-alive delay in seconds.
Definition tcp_stream.cc:33
TcpStream(std::unique_ptr< uv_tcp_t > tcp)
Definition tcp_stream.h:24
TcpStream & operator=(const TcpStream &)=delete
TcpStream(TcpStream &&)=default
TcpStream & operator=(TcpStream &&)=default
TcpStream(const TcpStream &)=delete
~TcpStream() override=default
AddressHandle getPeerName() const
Return address of peer.
Definition tcp_stream.cc:24
void noDelay(bool enable)
Enable Nagle's algorithm.
Definition tcp_stream.cc:37
Definition async_work.cc:18