HI all.
Firstly, I am not normally a Perl developer...I tinker with it when I need a specific solution....so forgive m if the below is obvious smile

What I have is a Perl script daemon that looks at a file using Tail and then outputs the data via a serial port. This works perfectly fine. BUT, I wanted to ramp it up a bit and instead of outputting the data via serial, I want to send it via TCP.
I googled around, and found some pretty simple code, but I get unexpected results.
Basically, I dont get any data output until I stop the daemon...which I only stumbled upon when testing.
Here is part of my code:-

my $sock = new IO::Socket::INET ( PeerAddr => '192.168.1.2', PeerPort => '8000', Proto => 'tcp' ); while (defined(my $line=$file->read)) { print TTY "$line"; #out serial print $sock "$line"; #out tcp } close($sock);

As you can see, not exactly complex.
I tried moving the "my $sock" init of the socjet to just above the "print $sock" line, then closeing the socket, but this didnt really work. I tried $sock->send(); but this didnt make any difference.

I am sure someone will spot the problem beable to tell.

Thanks, Jeremy

Edit: g0n - code tags & formatting


In reply to Perl Sockets question by jimbo

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.