小编Fra*_*hay的帖子

简单的Perl Websocket客户端

我正在尝试在Perl中编写一个简单的websocket客户端:

use Protocol::WebSocket::Client;

my $client = Protocol::WebSocket->new(url => 'ws://myserver:port');

# Sends a correct handshake header
$client->connect;

# Register on connect handler
$client->on(
    connect => sub {
        $client->write('hi there');
    }
);

# Parses incoming data and on every frame calls on_read
$client->read($reply);
print "$reply\n";

# Sends correct close header
$client->disconnect;
Run Code Online (Sandbox Code Playgroud)

的文档中Protocol::WebSocket::Client所示,但我收到以下消息:

Can't locate object method "new" via package "Protocol::WebSocket" at ./webSocketClient.pl.
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

perl client websocket

3
推荐指数
1
解决办法
5368
查看次数

标签 统计

client ×1

perl ×1

websocket ×1