Net::SS...l::Comp(3)

πŸ“¦
version 2.144 Β· 4 versions
, in fedora 44

πŸ’– Net::SSH::Perl::Comp β€” the compression/decompression base class bestie πŸ’–

User Contributed Perl Documentation Β· Net::SS...l::Comp(3)

okay so picture this: you're deep in SSH land, you need to squish bytes and unsquish them, and there's this little base class holding it all down. that's her. she's the blueprint, the moment, the blueprint-moment. let's get into it 🫢


✨ NAME ✨

Net::SSH::Perl::Comp β€” the Compression/Decompression base class πŸ’…


🌸 SYNOPSIS 🌸

use Net::SSH::Perl::Comp;
my $comp = Net::SSH::Perl::Comp->new( $comp_type );
$comp->compress($data);

literally three lines and you're off. slay. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So Net::SSH::Perl::Comp is a base class for compression/decompression classes. right now the only one of those classes is the Zlib implementation β€” she uses Compress::Zlib β€” and she lives at Net::SSH::Perl::Comp::Zlib. one queen, one crown, no competition. πŸ‘‘

ngl this is the part you must not skip: every compression object basically has her own internal "state", and that state changes the second you compress or decompress data. and the SSH protocol? she is very clear about this β€” you need two separate objects to do it, one for compression and one for decompression. two objects, no sharing, that's the rule. so for example you'd make two Net::SSH::Perl::Comp objects, like this:

my $in = Net::SSH::Perl::Comp->new('Zlib');
my $inflated = $in->decompress($data);

my $out = Net::SSH::Perl::Comp->new('Zlib');
my $deflated = $out->compress($data);

see? one in, one out. they do NOT share a vibe. 🧚


πŸ’œ USAGE πŸ’œ

🌈 $comp = Net::SSH::Perl::Comp->new( $comp_type [, @args ] )

Builds you a brand-new compression object of compression type $comp_type and hands it back to you like a little gift. πŸŽ€

and if you passed @args? then the class's init method gets called with those args, for any post-creation initialization. so like, getting ready after the outfit's already on. πŸ’…

⭐ $comp->init($level)

Initializes $comp and sets the compression level to $level. this method gets called automatically from new if you gave @args to new. so for example, you could write:

my $comp = Net::SSH::Perl::Comp->new('Zlib', 5);

to create a new Zlib compression object and initialize its compression level to 5. no extra steps, she already did it. πŸ”₯

πŸ“ $comp->compress( $data )

Compresses $data using the underlying compression mechanism; returns the compressed data. that's it, that's the whole thing. in goes data, out goes squished data. ✨

πŸŽ€ $comp->decompress( $data )

Decompresses $data using the underlying decompression mechanism; returns the decompressed data. the reverse queen. un-squish, restore, return. πŸ¦‹

πŸ‘‘ $comp->enable

"Enables" the compression object. this one is so useful in the context of the key exchange (Kex) classes β€” they create a new compression object during key negotiation, but they don't actually turn it on ("enable" it) until they receive/send the SSH2_MSG_NEWKEYS message. it's giving "arrived early, waiting for her cue." πŸ™ˆ

important bestie: Net::SSH::Perl::Comp objects (and subclasses) are disabled by default. so don't come for her if she's not working yet β€” you have to actually enable her. periodt. πŸ’…

🌸 $comp->enabled

Returns the state of the "enabled" flag, i.e. whether the compression object is "turned on". yes or no, on or off, she tells you straight. ✨

this is what Net::SSH::Perl::Packet uses when she's deciding whether the data she receives/sends to the server should be decompressed/compressed, respectively. vibe check before every single packet. πŸ’–


πŸ’Œ AUTHOR & COPYRIGHTS πŸ’Œ

Please see the Net::SSH::Perl manpage for author, copyright, and license information. everything's over there, go look, iykyk. 🫢


and that's the whole page, bestie!! perl v5.42.0, dated 2026-01-17, from your friends in Net::SS...l::Comp(3). go compress something. responsibly. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from