#!/usr/bin/perl

use IO::Socket::INET;

# flush after every write
$| = 1;

my ($socket,$req,$resp);

#  We call IO::Socket::INET->new() to create the UDP Socket
# and bind with the PeerAddr.

$socket = new IO::Socket::INET (PeerAddr=>'127.0.0.1:5060', Proto=>'udp');

for($i = 1; $i <= 1000; $i++) {
#send operation
my $req;
  $req.= "SUBSCRIBE sip:2\@127.0.0.1 SIP/2.0\r\n";
  $req.= "Via: SIP/2.0/UDP 127.0.0.1:2048;branch=z9hG4bK-xukt9d83jat4;rport\r\n";
  $req.= "To: <sip:2\@127.0.0.1>\r\n";
  $req.= "From: <sip:sipp\@127.0.0.1>\r\n";
  $req.= "Call-ID: 33xxx-kris\r\n";
  $req.= "CSeq: $i SUBSCRIBE\r\n";
  $req.= "Contact: <sip:memleak\@127.0.0.1:2048>\r\n";
  $req.= "Event: dialog\r\n";
  $req.= "Accept: application/dialog-info+xml\r\n";
  $req.= "Expires: 300\r\n";
  $req.= "Content-Length: 0\r\n\r\n";

$socket->send($req);

#read operation
$resp = <$socket>;
#print "Data received from socket : $resp\n";
select(undef, undef, undef, 0.01);

}

$socket->close();

