#!/usr/bin/perl use Net::EasyTCP; # a client $client = new Net::EasyTCP( mode => "client", host => 'localhost', port => 2345, password => ztest ) || die "ERROR CREATING CLIENT: $@\n"; my $encrypt = $client->encryption(); my $compress = $client->compression(); print "encryption method ->$encrypt\ncompression method ->$compress\n"; my $encryption = $client->encryption() || "NO"; my $compression = $client->compression() || "NO"; print "Using $encryption encryption and $compression compression\n\n"; #Send and receive a simple string $client->send("HELLO THERE") || die "ERROR SENDING: $@\n"; $reply = $client->receive() || die "ERROR RECEIVING: $@\n"; print "$reply\n"; #Send and receive complex objects/strings/arrays/hashes by reference #%hash = ("to be or" => "not to be" , "just another" => "perl hacker"); #$client->send(\%hash) || die "ERROR SENDING: $@\n"; #$reply = $client->receive() || die "ERROR RECEIVING: $@\n"; #foreach (keys %{$reply}) { #print "Received key: $_ = $reply->{$_}\n"; #} #Send and receive large binary data #for (1..4096) { #for (0..255) { #$largedata .= chr($_); #} #} #$client->send($largedata) || die "ERROR SENDING: $@\n"; #$reply = $client->receive() || die "ERROR RECEIVING: $@\n"; #$client->close(); $client->send('Hello from Joe') || die "ERROR SENDING: $@\n"; $reply = $client->receive() || die "ERROR RECEIVING: $@\n"; print "$reply\n"; while(1){ $input = ; $client->send($input) || die "ERROR SENDING: $@\n"; $reply = $client->receive() || die "ERROR RECEIVING: $@\n"; print "$reply\n"; }