Skip to content

Instantly share code, notes, and snippets.

@bioduds
Created June 11, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bioduds/629b1f88e1a778f13309f5651659319f to your computer and use it in GitHub Desktop.
Save bioduds/629b1f88e1a778f13309f5651659319f to your computer and use it in GitHub Desktop.
How to respond now
### So, I got this to listen to incoming requests
#unit package EC::Network:auth<github:bioduds>;
unit module EC::Network;
class Socket {
has $.listener;
method run {
loop {
my $conn = $!listener.accept;
while my $buf = $conn.recv( :bin ) {
$conn.write: $buf;
say "yo from listener";
}
$conn.close;
}
}
}
### called by
use v6;
use lib 'lib/network';
use p2p;
say "Running Test...";
EC::Network::Socket.new(
:listener( IO::Socket::INET.new(
:listen, :localhost<192.168.1.106>, :localport(5000) ) ) ).run;
### Here's the output
BITWORKERS dev # perl6 test.p6
Running Test...
yo from listener
yo from listener
yo from listener
yo from listener
yo from listener
yo from listener
yo from listener
yo from listener
yo from listener
#### each yo from listener was a call made from Postman in a different computer inside the LAN
### Now how do I respond??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment