TCP/IP using perl

TCP/IP using perl

Ori Idan ori at helicontech.co.il
Sat Apr 7 10:20:35 IDT 2012


I have a simple device that I need to send few lines of data in TCP
protocol.
The device should respond on each line sent.

I am using the following code:

#!/usr/bin/perl
use IO::Socket::INET;

my ($socket,$client_socket);

$socket = new IO::Socket::INET (
PeerHost => '192.168.0.20',
PeerPort => '5086',
Proto => 'tcp',
) or die "ERROR in Socket Creation : $!\n";


$socket->send("a\n");
$socket->recv($data, 128);
print "Data 1: $data\n";

$socket->send("111000\n");
$socket->recv($data, 128);

It seems that the device gets the first line but not the second line.
Does anyone have an idea what am I doing wrong?

-- 
Ori Idan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20120407/1fad8490/attachment.html>


More information about the Linux-il mailing list