Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

Sorry to bother~~~ I'm trying to make a websocket implementation and the result is below:

>perl client.pl

client receive message: #client say : Hello, world!

#client receive message: ##client receive message:

#client say : Hello, world!

#client receive message: #client say : Hello, world!

#client receive message: #client say : Hello, world! ....

As you see, it loop infinitely sending messages with server if I used perl interpreter to execute(type 'perl client.pl'). But when I used perl2exe to compile my program to EXE and then execute, the client.exe can not loop anymore. I do not know what happened because I did not meet any error message. The result as below:

>client.exe

>

My code(client.pl) as below:

#!/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;