Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: No data received on client socket

by rbi (Monk)
on Sep 21, 2006 at 14:59 UTC ( [id://574145]=note: print w/replies, xml ) Need Help??


in reply to No data received on client socket

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;

Replies are listed 'Best First'.
Re^2: No data received on client socket
by ikegami (Patriarch) on Sep 21, 2006 at 15:52 UTC

    Which change fixed it? Did using while (<FH>) or fixing the options passed to the constructor fix it?

    SOCK_STREAM is 1, but 'SOCK_STREAM' probably got treated as 0. If that's the problem, you should go back to using sysread/syswrite.

    By the way, what's with local *FH = $oSocket;? Everywhere you use FH, you can put $oSocket. (e.g. print $oSocket ..., while (<$oSocket>), sysread($oSocket, ...), etc)

      It worked when I put while(<FH>) and kept working when I forced the while condition to be true.
      Thanks for the correction on directly using the $oSocket.

      The same code accessing the same SQL server has a different behavior on different Linux boxes.. I hope this fix will work on the old ones :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://574145]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found