aodukoya has asked for the wisdom of the Perl Monks concerning the following question:
$ ./tester -local + Starting up the test util in single user mode ... + TestUtil>qry chk table testa + TESTA .............................Table Exists(ok) + TestUtil>qry chk table testb + TESTB .............................Table Exists(ok) + TestUtil>dml upd table testb + The where clause on testb is based on where object_id equals, please g +ive a valid value: 90 UpdTab> The sql is update testb set object_name = 'Shareplex' where ob +ject_id = ? The value entered is 90 + The number of rows Updated from testb is 1 + TestUtil>qry chk data testb + The total number of rows for testb is 82 + The number of modified rows are 2 + TestUtil> TestUtil>quit
$ ./tester -local Starting up the test util with network enabled... TestUtil>ddl drp table testa I have received your message[server]-THISISTHEEND DATA in $data slice 1 is THISISTHEEND I have received your message[server]-THISISTHEEND DATA in $data slice 1 is THISISTHEEND TestUtil>ddl create table testa <-it hangs and I have to ctrl+C out
#!/usr/bin/perl + use warnings; use strict; use IO::Socket qw(:DEFAULT :crlf); my $port = $ENV{CM_PORT} || 3013 ; my $host = $ENV{CM_HOSTS} || 'uksupu02' ; my $read ; my $quit ; my $utilprmpt = 'Testing> '; my $socket ; my $user_input = 'start' ; RERUN_PROMPT: while ( $user_input ne 'quit') { + print "$utilprmpt"; + chomp ( $user_input = <>); + if (!$user_input){next RERUN_PROMPT } ; if ($user_input =~/^\s+$/){ next RERUN_PROMPT } ; if ( $user_input eq 'quit') { exit }; &CreateClient ; + } + + sub CreateClient { + $socket = IO::Socket::INET->new("$host:$port") or die "can't create s +ocket: $!"; user_to_host ($socket, $user_input) ; + &host_to_user ($socket); + } + sub user_to_host { + my $sock = shift; + my $msg = shift ; + print $sock $msg ,CRLF; + } + sub host_to_user { + my $sock = shift ; + my $nread ; + my $inp ; + $/ = CRLF ; + while (<$sock>) { + chomp; + my @data = split/-/, $_ ; + print $_ , "\n"; + if ($data[1] eq 'THISISTHEEND') { + return ; + } + } + }
#!/usr/bin/perl + use warnings; use strict; use IO::Socket qw(:DEFAULT :crlf) ; my $port = $ENV{CM_PORT} || 3013 ; + my $quit = 0 ; my $session ; my $sock ; $SIG{INT} = sub { $quit++ } ; sub server { $sock = IO::Socket::INET->new( Listen => 5, LocalPort => + $port, Timeout => 60*60, Reuse => 1 ) or die "Can't create li +stening socket: $!\n"; warn "Waiting for incoming connections on port $port...\n"; + } &server ; + while ( !$quit ) { + next unless $session = $sock->accept; my $pport = $session->peerport; my $paddr = $session->peeraddr; my $pname = gethostbyaddr($paddr, AF_INET); my $peer = "$pname:$pport" ; warn "Connection from [$peer]\n"; while (<$session>){ chomp; my $msg_recv = $_ ; my $msg_out = ("I have received your message[server]-THISIS +THEEND") . CRLF ; print $session $msg_out ; print " Received=> $msg_recv \n"; } + warn "Connection from [$peer] finished\n"; close $session ; + }
Edited by theorbtwo: Moved from a reply to New user scratch pad. to a root SoPW.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Client-Server Programme hangs...
by Errto (Vicar) on Dec 31, 2004 at 00:53 UTC | |
by aodukoya (Initiate) on Dec 31, 2004 at 01:44 UTC | |
by Errto (Vicar) on Dec 31, 2004 at 17:02 UTC | |
by aodukoya (Initiate) on Jan 04, 2005 at 08:07 UTC | |
by Errto (Vicar) on Jan 05, 2005 at 03:33 UTC |