As of right now I'm just dipping into the world of sockets. What I'm trying to do is pipe output from a QNX machine using perl to a w2k machine. So far everything works. The problem is on the qnx side it is always sending information (which is good) but on the client side (w2k) it isn't appending out the info to a file in real time. To elaborate...If the client is shut down nothing is written to the file. As an overview what I’m trying to do is get the information to my w2k machine to do some heavy possessing on that data. I would like to crunch all the numbers while the info is still flowing. Here is what I’ve attempted to do so far. Does anyone have a way to solve the problem are know of a better or more proficient way of accomplishing this? here is the part of the server that is realaying information.
use IO::Socket; my $sock = new IO::Socket::INET ( LocalHost => 'qnxa227', LocalPort => '7070', Proto => 'tcp', Listen => 1, Reuse => 1 ); die "Could not creat socket: $!\n" unless $sock; $sock->autoflush(1); print "The server is up and ready\n"; my $new_sock =$sock ->accept() || die " error $new_sock"; #### This just goes around an infinite loop gathering info while(1){ sleep(2); if( $ARGV[0] eq "l"){ & short; print "\n"; & long; } elsif( $ARGV[0] eq "lp"){ & short; print "\n"; & pfilter; } else { @x = (& short( $new_sock)); print($new_sock $x[0]),"\n"; print($new_sock $x[1]),"\n"; print($new_sock $x[2]),"\n"; } } close($sock);
And here is the client side....
use IO::Socket::INET; $file = "info.txt"; #open(stdout,">>$file"); ### one way of trying to output to a file $sock = IO::Socket::INET->new( PeerAddr => '10.8.74.227', PeerPort => '7070', Proto => 'tcp'); print "client running\n"; my $byte; while (sysread($sock, $byte, 1) == 1) { print $byte; } close($sock);
Thanks A Lot!

In reply to Sockets and Output by maxl90

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.