Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initialization commit.

Creat editor.pl and listener.pl
  • Loading branch information...
commit 8505c8303d2954e3707947170440a3e0e72efd37 1 parent 2ae07ea
Geng Shuang authored
Showing with 43 additions and 0 deletions.
  1. +19 −0 editor.pl
  2. +24 −0 listener.pl
View
19 editor.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use IO::Socket;
+
+my $sock = new IO::Socket::INET (
+ PeerAddr => 'gengs-host',
+ PeerPort => 1200,
+ Proto => 'tcp',
+) or die $!;
+
+foreach (1..10) {
+ print $sock "Msg $_: How are you ?\n";
+ $sock -> flush();
+}
+
+close $sock;
View
24 listener.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use IO::Socket;
+
+my $sock = new IO::Socket::INET(
+ Localhost => 'gengs-host',
+ LocalPort => 1200,
+ Proto => 'tcp',
+ Listen => 5,
+ Reuse => 1,
+);
+
+die "Could not connet : $!" unless $sock;
+
+while (my $new_sock = $sock -> accept()) {
+ while (defined (my $buf = <$new_sock>)) {
+ print $buf;
+ }
+}
+
+close $sock;
Please sign in to comment.
Something went wrong with that request. Please try again.