I could finally get back the query result by modifying the original script like this:
my $oSocket = IO::Socket::INET->new(PeerAddr => $HostName,
+
PeerPort => $Port,
+
Timeout => $SocketTimeout,
Type => SOCK_STREAM);
my $sSend = "<?xml version=\"1.0\"?> <request>" .
"<connectionstring>" . $ConnectionString .
"</connectionstring>" .
"<sql><![CDATA[" . $sSQL . "]]></sql></request>";
+
local *FH = $oSocket;
print FH $sSend;
while (<FH>) { print $_ };
I'd really be grateful if someone can explain me what is not working in the other ways (my original one and the suggested modifications), and how the other ones should be modified in order to work.
Thanks a lot.
Update This way it works fine:
...
local *FH = $oSocket;
print FH $sSend;
while (1) {
sysread($oSocket, $data_read, 4096,length($data_read));
$sRet .= $data_read;
last if ($data_read =~ /<\/xml>/i);
};
close (FH);
print $sRet;