#!/usr/bin/perl use IO::Socket; use Tk; $socket = new IO::Socket::INET ( PeerAddr => '10.101.3.55', PeerPort => 5000, Proto => 'tcp', ) or die "Couldn't connect to Server\n"; die "Could not connect: $!" unless $socket; my ($txt,$mw,$frm_name,$lab,$ent,$txt,$but); $mw= MainWindow->new(); while (1) { #print "hi\n"; $socket->recv($recv_data,1024); if ($recv_data eq 'q' or $recv_data eq 'Q') { close $socket; last; } else { $frm_name = $mw -> Frame() -> pack(); $lab = $frm_name -> Label(-text=>"Name:") -> pack(); $ent = $frm_name -> Entry() -> pack(); $txt = $mw -> Text(-width=>40, -height=>10) -> pack(); print "RECIEVED: $recv_data"; my $data=$recv_data; $but = $mw -> Button(-text=>"Push Me", -command =>sub { #print "\nSEND( TYPE q or Q to Quit):"; $txt -> insert('end',"$data"); $send_data = $ent -> get(); chop($send_data); if ($send_data ne 'q' and $send_data ne 'Q') { $socket->send($send_data); } else { $socket->send($send_data); close $socket; last; } })->pack(); Tk::MainLoop; } }