|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 1 #ifndef SPONGE_LIBSPONGE_TCP_SPONGE_SOCKET_HH
2 #define SPONGE_LIBSPONGE_TCP_SPONGE_SOCKET_HH
20 template <
typename AdaptT>
33 std::optional<TCPConnection>
_tcp{};
141 #endif // SPONGE_LIBSPONGE_TCP_SPONGE_SOCKET_HH
LocalStreamSocket _thread_data
Stream socket for reads and writes between owner and TCP thread.
Waits for events on file descriptors and executes corresponding callbacks.
void connect(const Address &address)
Helper class that makes a TCPOverIPv4overEthernetSpongeSocket behave more like a (kernel) TCPSocket.
void set_reuseaddr()=delete
void connect(const Address &address)
std::optional< TCPConnection > _tcp
TCP state machine.
std::thread _tcp_thread
Handle to the TCPConnection thread; owner thread calls join() in the destructor.
Wrapper around IPv4 addresses and DNS operations.
std::atomic_bool _abort
Flag used by the owner to force the TCPConnection thread to shut down.
Config for classes derived from FdAdapter.
A wrapper around Unix-domain stream sockets.
AdaptT _datagram_adapter
Adapter to underlying datagram socket (e.g., UDP or IP)
Address peer_address() const =delete
void connect(const TCPConfig &c_tcp, const FdAdapterConfig &c_ad)
Connect using the specified configurations; blocks until connect succeeds or fails.
TCPSpongeSocket(std::pair< FileDescriptor, FileDescriptor > data_socket_pair, AdaptT &&datagram_interface)
Construct LocalStreamSocket fds from socket pair, initialize eventloop.
Address local_address() const =delete
bool _fully_acked
Has the outbound data been fully acknowledged by the peer?
Config for TCP sender and receiver.
void _tcp_loop(const std::function< bool()> &condition)
Process events while specified condition is true.
Helper class that makes a TCPOverIPv4SpongeSocket behave more like a (kernel) TCPSocket.
void listen_and_accept(const TCPConfig &c_tcp, const FdAdapterConfig &c_ad)
Listen and accept using the specified configurations; blocks until accept succeeds or fails.
bool _inbound_shutdown
Has TCPSpongeSocket shut down the incoming data to the owner?
~TCPSpongeSocket()
When a connected socket is destructed, it will send a RST.
void bind(const Address &address)=delete
TCPSpongeSocket & operator=(const TCPSpongeSocket &)=delete
EventLoop _eventloop
eventloop that handles all the events (new inbound datagram, new outbound bytes, new inbound bytes)
bool _outbound_shutdown
Has the owner shut down the outbound data to the TCP connection?
void _initialize_TCP(const TCPConfig &config)
Set up the TCPConnection and the event loop.
Multithreaded wrapper around TCPConnection that approximates the Unix sockets API.
void _tcp_main()
Main loop of TCPConnection thread.