0

perl example

I been looking for example on how to send commands with the IP interface. Had to do my own.

Here is a real simple perl example.You'll need to change the IP address to what you  are using

 

#---

#
#

use IO::Socket::INET;

# flush after every write
$| = 1;

my ($socket,$client_socket);

# creating object interface of IO::Socket::INET modules which internally creates
# socket, binds and connects to the TCP server running on the specific port.
$socket = new IO::Socket::INET (
    PeerHost => '192.168.1.70',
    PeerPort => '4998',
    Proto => 'tcp',
) or die "ERROR in Socket Creation : $!\n";

print "TCP Connection Success.\n";

# send iTach command getdevices
$data = "getdevices\r";
$socket->send($data);
sleep (1);
$socket->recv($data,1024);
print "Received from Server : $data\n";


$socket->close();

print "socket closed\n";

0 comments

Please sign in to leave a comment.