NAME
Tailscale::TcpStream - a TCP connection over Tailscale
SYNOPSIS
# Obtained from Tailscale->tcp_connect or TcpListener->accept
my $stream = $ts->tcp_connect("100.64.0.2:80");
$stream->send_all("Hello");
my $reply = $stream->recv(4096);
$stream->close();
DESCRIPTION
Represents a bidirectional TCP byte stream between two Tailscale nodes. You do not construct this directly; it is returned by "tcp_connect" in Tailscale or "accept" in Tailscale::TcpListener.
METHODS
send
my $n = $stream->send($data);
Sends bytes to the peer. Returns the number of bytes actually sent, which may be less than length($data). Blocks until at least one byte is sent. Dies on error.
send_all
$stream->send_all($data);
Sends all of $data, looping internally until every byte has been written. Returns the total number of bytes sent.
recv
my $data = $stream->recv($maxlen);
Receives up to $maxlen bytes from the peer (default 4096). Blocks until at least one byte is available. Returns undef on EOF. Dies on error.
close
$stream->close();
Closes the stream and releases the underlying handle. Also called automatically when the object is destroyed.
SEE ALSO
Tailscale, Tailscale::TcpListener
AUTHOR
Brad Fitzpatrick <brad@danga.com>
LICENSE
BSD-3-Clause