#!/usr/bin/perl #use strict; # use both POE server and the filter needed use POE qw(Component::Server::TCP Filter::Reference); use CUPPS::Cupps; my $Dest = Value("DestinationXMLLocation"); my $Src = Value("SourceXMLLocation"); POE::Component::Server::TCP->new( Alias => "sum_server", Port => 11211, ClientFilter => "POE::Filter::Reference", ClientPreConnect => sub { sleep(1); $socket = $_[ARG0]; sysread($socket, $buf, 1000); print "Result = $buf\n"; open(FH,"$Src\\interfaceLevelsAvailableResponse-OK.xml"); $buf = join("", ); close(FH); print "\n"; syswrite($socket, $buf, 1000); print "\n"; $buffer = $buf; while ($buffer eq $buf) { sysread($socket, $buf, 1000); } print "Result = $buf\n"; open(FH,"$Src\\interfaceLevelResponse-OK.xml"); $buf = join("", ); close(FH); syswrite($socket, $buf, 1000); }, ClientInput => sub { }, ); POE::Component::Server::TCP->new( Alias => "sum_server", Port => 11212, ClientFilter => "POE::Filter::Reference", ClientPreConnect => sub { sleep(1); $socketd = $_[ARG0]; sysread($socketd, $bufd, 1000); print "Result = $bufd\n"; open(FHD,"$Src\\authenticateResponse-OK.xml"); $bufd = join("", ); close(FHD); print "\n"; syswrite($socketd, $bufd, 1000); print "\n"; $bufferd = $bufd; while ($bufferd eq $bufd) { sysread($socketd, $bufd, 1000); } print "Result = $bufd\n"; open(FHD,"$Src\\byeResponse-OK.xml"); $bufd = join("", ); close(FHD); syswrite($socketd, $bufd, 1000); }, ClientInput => sub { }, ); $poe_kernel->run(); exit 0; #### #!/usr/bin/perl -w #use strict; use POE; use POE::Component::Client::TCP; use POE::Filter::Reference; #use POE::Session::MultiDispatch; use CUPPS::Cupps; my $host = "localhost"; # The host to test. my $port = 11211; my $Dest = Value("DestinationXMLLocation"); my $Src = Value("SourceXMLLocation"); POE::Component::Client::TCP->new( RemoteAddress => $host, RemotePort => $port, #SessionType => "POE::Session::MultiDispatch", Filter => "POE::Filter::Reference", PreConnect => sub { my ($socket, $peer_addr, $peer_port) = @_[ARG0, ARG1, ARG2]; print "connected to $host:$port ...\n"; open(FH,"$Src\\interfaceLevelsAvailableRequest.xml"); my $buf = join("", ); close(FH); syswrite($socket, $buf, 1000); print "\n"; $buffer = $buf; while ($buffer eq $buf) { sysread($socket, $buf, 1000); } print "Result = $buf\n"; open(FH,"$Src\\interfaceLevelRequest.xml"); $buf = join("", ); close(FH); print "\n"; syswrite($socket, $buf, 1000); sleep(1); print "\n"; $buffer = $buf; while ($buffer eq $buf) { sysread($socket, $buf, 1000); } $socket->autoflush(1); print "Result = $buf\n"; }, Connected => sub { }, ConnectError => sub { print "could not connect to $host:$port ...\n"; }, ServerInput => sub { }, ); my $port1 = 11212; POE::Component::Client::TCP->new( RemoteAddress => $host, RemotePort => $port1, #SessionType => "POE::Session::MultiDispatch", Filter => "POE::Filter::Reference", PreConnect => sub { my ($socketd, $peer_addrd, $peer_portd) = @_[ARG0, ARG1, ARG2]; print "connected to $host:$port1 ...\n"; open(FHD,"$Src\\authenticateRequest.xml"); my $bufd = join("", ); close(FHD); syswrite($socketd, $bufd, 1000); print "\n"; $bufferd = $bufd; while ($bufferd eq $bufd) { sysread($socketd, $bufd, 1000); } print "Result = $bufd\n"; open(FHD,"$Src\\byeRequest.xml"); $bufd = join("", ); close(FHD); print "\n"; syswrite($socketd, $bufd, 1000); sleep(1); print "\n"; $bufferd = $bufd; while ($bufferd eq $bufd) { sysread($socketd, $bufd, 1000); } print "Result = $bufd\n"; }, Connected => sub { }, ConnectError => sub { print "could not connect to $host:$port ...\n"; }, ServerInput => sub { }, ); POE::Kernel->run(); exit 0;