dwatson06 has asked for the wisdom of the Perl Monks concerning the following question:

I am in the process of writing a server that will accept an xml file, parse it, then send a response back based on the file.

I have successfully written the Server and a mock Client in Perl which communicate wonderfully through a tcp connection on port 80. The problem is, when the actual client connects using their client app, it passes a POST header which the server takes in but it stops responding when the xml data is passed.

At this point I want to take in all the information from the client request. I have a packet sniffer open and it's showing me the POST request which the server accepts and writes. After that, the sniffer shows a continuation which holds the XML data from the client. The server stops after printing the Header POST, and no XML is printed.

use IO::Socket; $local = IO::Socket::INET->new( Proto => 'tcp', LocalAddr => '', Reuse => 1 ) or die "$!"; $local->listen(); print "Awaiting client...\n"; my $addr; while ($addr = $local->accept() ) { print "Connecting from: ", $addr->peerhost(); print " Port: ", $addr->peerport(), "\n"; while (<$addr>) { print "Client: $_"; } close $addr; # close client print "Idle...\n"; }

Any suggestions would be greatly appreciated.

Thank you,

Replies are listed 'Best First'.
Re: Problems accepting client data
by Zaxo (Archbishop) on Apr 21, 2004 at 20:22 UTC

    Since the real client is connecting to port 80 amd sending a POST request, I'm sure it thinks it is to speak http. You can either change port and protocol, or use HTTP::Daemon, or else let httpd do the heavy lifting through a handler (written in perl, of course :-)

    After Compline,

Re: Problems accepting client data
by Fletch (Bishop) on Apr 21, 2004 at 20:50 UTC

    Or just use RPC::XML::Server or SOAP::Lite and a standard protocol with off the shelf client and server components and be done with it (not to mention interoperable with a whole bunch of other things other than perl).

Re: Problems accepting client data
by NetWallah (Canon) on Apr 21, 2004 at 20:32 UTC
    You may want to set $OUTPUT_AUTOFLUSH (If use English), or $| =1;

    Just a guess - if the XML does not contain Line Feeds, the output to the console will stay in the buffer, unless $| is non-zero.

    Offense, like beauty, is in the eye of the beholder, and a fantasy.
    By guaranteeing freedom of expression, the First Amendment also guarntees offense.
      I had AutoFlush set but I was reading somewhere that it was Defaulted now. I will reset it anyway, it doesn't hurt anything. It does appear to be hanging in the buffer though. Is there another reason the response would stay in the buffer?