![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
PCAPNG sink that streams capture bytes to connected clients over TCP. More...
#include <dfx-pcapng/sinks/TcpSink.hpp>
Public Types | |
| using | Server = Server::TcpServerForSession<WriteOnlySession> |
| Server type used by this sink (write-only sessions). | |
| using | ServerPtr = std::unique_ptr<Server> |
| Owning pointer to the server instance. | |
Public Member Functions | |
| TcpSink (std::string host="localhost", uint16_t port=19 '000) | |
Construct a TCP sink listening on host: | |
| void | init (std::vector< uint8_t > initialHeader) override |
| Initialize the sink and start the TCP server. | |
| void | write (std::vector< uint8_t > data) override |
| Broadcast serialized PCAPNG bytes to all connected clients. | |
| Public Member Functions inherited from dfx::Pcapng::Sink | |
| Sink () noexcept=default | |
| Construct a sink. | |
| DISABLE_COPY_AND_MOVE (Sink) | |
| Sinks are not copyable and not movable. | |
| virtual | ~Sink ()=default |
| Virtual destructor for polymorphic use. | |
| void | setPoller (FdWatch::Poller *poller) |
| Provide a poller that the sink may use for event-driven I/O. | |
Additional Inherited Members | |
| Protected Attributes inherited from dfx::Pcapng::Sink | |
| FdWatch::Poller * | _poller = nullptr |
| Borrowed poller pointer for event-driven sink implementations. | |
PCAPNG sink that streams capture bytes to connected clients over TCP.
TcpSink is a concrete Sink implementation that exposes the capture stream over a TCP server socket.
Internally it creates a dfx::Server::TcpServerForSession using a write-only session type (WriteOnlySession). Each connected client receives:
This sink is designed for live capture streaming to external consumers.
Server type used by this sink (write-only sessions).
| using dfx::Pcapng::TcpSink::ServerPtr = std::unique_ptr<Server> |
Owning pointer to the server instance.
| dfx::Pcapng::TcpSink::TcpSink | ( | std::string | host = "localhost", |
| uint16_t | port = 19 '000 ) |
Construct a TCP sink listening on host: port.
The server is not created until init() is called.
| host | Host/interface to bind to (default: "localhost"). |
| port | TCP port to listen on (default: 19000). |
|
overridevirtual |
Initialize the sink and start the TCP server.
initialHeader immediately to the client.| initialHeader | Serialized PCAPNG header bytes to send to clients. |
Implements dfx::Pcapng::Sink.
|
overridevirtual |
Broadcast serialized PCAPNG bytes to all connected clients.
Iterates all current sessions and sends data to each of them. Clients that connect later will still receive the initial header from init() via the new-session callback.
| data | Bytes to send. |
Implements dfx::Pcapng::Sink.