Protoc...bSocket(3pm)
π NAME π
okay so this is the Protocol::WebSocket(3pm) page from the User Contributed Perl Documentation, and the module itself is literally called Protocol::WebSocket β the WebSocket protocol π
β¨
π¦ SYNOPSIS π¦
# Server side
my $hs = Protocol::WebSocket::Handshake::Server->new;
$hs->parse('some data from the client');
$hs->is_done; # tells us when handshake is done
my $frame = $hs->build_frame;
$frame->append('some data from the client');
while (defined(my $message = $frame->next)) {
if ($frame->is_close) {
# Send close frame back
send(
$hs->build_frame(
type => 'close',
version => $version
)->to_bytes
);
return;
}
# We got a message!
}
πΈ DESCRIPTION πΈ
bestie, Protocol::WebSocket is a client/server WebSocket message and frame parser/constructor. It does not hand you a full WebSocket server or client β it's made for using in http servers or clients so they can provide WebSocket support π«Ά
It supports these WebSocket protocol versions, no cap:
draft-ietf-hybi-17 (latest)draft-ietf-hybi-10draft-ietf-hybi-00 (with HAProxy support)draft-hixie-75
By default, the latest version is used β periodt. On the server side, the WebSocket version gets detected automatically β¨ On the client side, you set a version attribute to an appropriate value.
real talk: Protocol::WebSocket itself does not contain any code and cannot be used directly π Instead, you gotta use the modules below.
π High-level modules π
Protocol::WebSocket::Serverβ server helper class, your server-side bestie π«ΆProtocol::WebSocket::Clientβ client helper class, the client-side icon π
π§ Low-level modules π§
Protocol::WebSocket::Handshake::Serverβ server handshake parser and constructor.Protocol::WebSocket::Handshake::Clientβ client handshake parser and constructor.Protocol::WebSocket::Frameβ WebSocket frame parser and constructor.Protocol::WebSocket::Requestβ low level WebSocket request parser and constructor.Protocol::WebSocket::Responseβ low level WebSocket response parser and constructor.Protocol::WebSocket::URLβ low level WebSocket url parser and constructor.
β EXAMPLES β
For examples on how to use Protocol::WebSocket with various event loops, see the examples/ directory in the distribution πβ¨
π CREDITS π
In order of appearance:
- Paul "LeoNerd" Evans
- Jon Gentle
- Lee Aylward
- Chia-liang Kao
- Atomer Ju
- Chuck Bredestege
- Matthew Lien (BlueT)
- Joao Orui
- Toshio Ito (debug-ito)
- Neil Bowers
- Michal Ε paΔek
- Graham Ollis
- Anton Petrusevich
- Eric Wastl
π AUTHOR π
Viacheslav Tykhanovskyi, "vti@cpan.org" π
π COPYRIGHT π
Copyright (C) 2010-2018, Viacheslav Tykhanovskyi.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10 β¨
mwah π β this whole vibe is Protoc...bSocket(3pm) from perl v5.42.0, dated 2019-03-13. bye bestie, go build something iconic ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Protocol-WebSocket 0.26-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms