NAME
Net::BitTorrent::Transport::TCP - TCP transport shim for Net::BitTorrent
SYNOPSIS
use Net::BitTorrent::Transport::TCP;
my $transport = Net::BitTorrent::Transport::TCP->new(
socket => $socket_handle
);
$transport->on('data', sub ($data) {
$protocol->receive_data($data);
});
DESCRIPTION
Net::BitTorrent::Transport::TCP provides a standardized interface for handling TCP-based peer connections within the loop-agnostic Net::BitTorrent framework.
It acts as an abstraction layer between the high-level Net::BitTorrent::Peer and the physical network socket. This allows the library to handle different connection types (TCP vs uTP) using the same high-level logic.
While Net::uTP handles its own congestion control and packetization, this class acts as a pass-through for raw TCP streams, allowing the protocol handlers to treat all connections uniformly.
ATTRIBUTES
socket
The underlying IO::Socket (or compatible) object.
METHODS
on( $event, $cb )
Registers a callback for an event (currently 'data', 'debug', or 'connected').
send_data( $data )
Buffers or returns data to be sent over the socket. In this shim implementation, it currently returns the data directly for the caller to handle.
receive_data( $data )
Triggers the 'data' event with the provided raw data.
state( )
Returns 'CONNECTED' or 'CLOSED' based on the status of the underlying socket.
AUTHOR
Sanko Robinson <sanko@cpan.org>
COPYRIGHT
Copyright (C) 2008-2026 by Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.