Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use IO::Socket;
- my $socket = new IO::Socket::INET (
- LocalHost => 'localhost',
- LocalPort => '4488',
- Proto => 'tcp',
- Listen => 1,
- Reuse => 1,
- );
- die "Could not create socket: $!\n" unless $socket;
- my $socket2 = new IO::Socket::INET (
- LocalHost => 'localhost',
- LocalPort => '4489',
- Proto => 'tcp',
- Listen => 1,
- Reuse => 1,
- );
- die "Could not create socket: $!\n" unless $socket2;
- print "SERVER Waiting for client connection on port";
- while(1){
- $client_socket = "";
- $client_socket = $socket->accept();
- $peer_address = $client_socket->peerhost();
- $peer_port = $client_socket->peerport();
- if($client_socket){print "\n I got a connection from DAISI ( $peer_address , $peer_port ) "};
- $web_socket = "";
- $web_socket = $socket2->accept();
- $peer_address_web = $web_socket->peerhost();
- $peer_port_web = $web_socket->peerport();
- if($web_socket){print "\n I got a connection from the WEB ( $peer_address_web , $peer_port_web ) "};
- while (1)
- {
- if($web_socket){
- $web_socket->recv($web_command, 1024);
- chop($web_command);
- if ($client_socket){
- $client_socket->send($web_command);
- } else {
- close $client_socket;
- last;
- }
- } else {
- close $web_socket;
- last;
- }
- }
- }
Add Comment
Please, Sign In to add comment