#!/usr/bin/perl use strict; use IO::Async::Loop; use IO::Async::Loop::Select; use IO::Async::Loop::Poll; use IO::Async::Notifier; use Net::Async::WebSocket::Client; use Net::Async::WebSocket::Protocol; use IO::Async::Internals::Connector; use IO::Async::Function; use IO::Async::Timer; use IO::Async::Routine; use IO::Async::ChildManager; my $client = Net::Async::WebSocket::Client->new( on_frame => sub { my ( $self, $frame ) = @_; print "client receive message: #$frame#"; }, ); # Define websocket Host & Port my $HOST = "localhost"; my $PORT = "8080"; my $loop = IO::Async::Loop->new; $loop->add( $client ); while( 1 ) { $client->connect( url => "ws://$HOST:$PORT/", )->then( sub { $client->send_frame( "client say : Hello, world!\n" ); })->get; } $loop->run;