Hello,

I took over as maintainer of Net::Daemon a number of years ago because I had a patch for it, because the maintainer at the time could not be found, and because the original author let me know he no longer does this sort of thing. One would have to know both threads and sockets programming, neither of which I actually know, but there was noone else. I need help now for Net::Daemon on Windows. Specifically, with some code in the file Net-Daemon\t\thread.t.

t/thread.t ...... Error while reading 0: 0 () at t/thread.t line 42.

A daemon child is opening up a handle to a port, then writing to it, flushing the handle, and then reading from the same handle. The writing to the handle works. The reading from the handle no longer works. The code used to work. Can anyone take a look at this?

To repeat the results,

The actual code from thread.t that fails is pasted below. The line with "Error while reading ..." is what always prints out. Again, this code always used to work. The $port number is typically in the 3 thousands range.

my($handle, $port) = Net::Daemon::Test->Child ($numTests, $^X, 't/server', '--timeout', 20, '--mode=threads'); print "Making first connection to port $port...\n"; $fh = IO::Socket::INET->new('PeerAddr' => '127.0.0.1', 'PeerPort' => $port); printf("%s 3\n", $fh ? "ok" : "not ok"); eval { for (my $i = 0; $i < 20; $i++) { if (!$fh->print("$i\n") || !$fh->flush()) { die "Error while writing $i: " . $fh->error() . " ($!)"; } my $line = $fh->getline(); die "Error while reading $i: " . $fh->error() . " ($!)" unless defined($line); die "Result error: Expected " . ($i*2) . ", got $line" unless ($line =~ /(\d+)/ && $1 == $i*2); } };

In reply to Cannot read socket fh in Net::Daemon test by mnooning

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.