use IO::Socket::INET; use strict; use Config::Tiny; use Config::Random; my ($DATA,$text,$msg, $array1); my @array; open TESTCASE, "imp2.txt" or die $!; while() { $array1 = $_; chomp $array1; $array[$incre]= $array1; $incre++; } open CONFIGFILE, "imp1.txt" or die $!; { local $/; $/ = undef; $DATA=; } my $Config = Config::ACTI->new(); $Config = Config::ACTI->read_string( $DATA ); $s = $Config->{_}; my $method= <\r From:sanjay;tag= abcd1250\r Max-Forwards: 70\r Call-ID: abchjhg1560@36.212.176.90\r CSeq: 1 REGISTER\r Contact:sanjay; expires=7200\r Content-Length:0\r \r END my $MySocket=new IO::Socket::INET->new( LocalAddr=>$s->{Local_IP}, LocalPort=>$s->{LocalPort}, PeerPort=>$s->{RemotePort}, Proto=>$s->{Transport}, PeerAddr=>$s->{Remote_IP} ); $MySocket or die "no socket :$!"; print "\nClient Started: Ready For Packet To Send:\n"; my $incre = 0; COND:for(;;) { last if $array[$incr] eq ''; if ($array[$incr] eq "[SEND]") { $incr++; if ($array[$incr] eq ("REGISTER" || "INVITE" || "ACK" || "BYE" || "OPTION" || "CANCEL")) { $incr++; goto OUTER; } else { print "Bad Request :$array[$incr]"; exit 1; } } elsif ($array[$incr] eq "[RECV]") { $incr++; if($array[$incr] == (100 || 200 || 300 || 400)) { $incr++; goto INNER; } else { print "Bad Response name:$array[$incr]"; exit 1; } } else { print "Bare word found:"; exit 1; } } OUTER:for(;;) { my $msg=$method; print "\nSending message:$msg"; $MySocket->send($msg); goto COND; } INNER:for(;;) { print "Waiting for Response:\n"; $MySocket->recv ($text,1000);#///Recv print "\nReceived message From:$text"; goto COND; } #### [SEND] REGISTER [RECV] 100 [RECV] 200