Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: (Seemingly) Broken interactions between Net::Server and IO::Pipe?

by tcf03 (Deacon)
on Mar 07, 2006 at 19:42 UTC ( #535008=note: print w/replies, xml ) Need Help??


in reply to (Seemingly) Broken interactions between Net::Server and IO::Pipe?

I get the following from that code
2006/03/07-14:16:21 CONNECT TCP Peer: "127.0.0.1:36018" Local: "127.0. +0.1:8097" testing! Use of uninitialized value in concatenation (.) or string at server.pl + line 23. Got: >Line = <
Looks like its doing what its supposed to. What version of Perl? Im using 5.8.5 under Linux.

UPDATE:
Or when connecting from a remote machine:
Got: >Line = <


Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson

Replies are listed 'Best First'.
Re^2: (Seemingly) Broken interactions between Net::Server and IO::Pipe?
by bmcatt (Friar) on Mar 07, 2006 at 20:23 UTC
    Nope, what you're seeing is exactly the broken behavior that I mentioned. This section:
    sub process_request { my $self = shift; my $x = Feeder->new(); my $line = $x->get_line(); print "Line = $line\n"; }
    should be reading the first line from the client file, so $line should be #!/usr/bin/perl -w. The fact that it's not set to anything means that the pipe's not working. I'm running with 5.8.8 under Linux as well. IO::Pipe is identifying itself as version 1.13 and Net::Server is version 0.90.
      I have never used IO::Pipe before, but from the docs it looks like you need to do a
      while(<$pipe>) { read from pipe... }
      when I run it it cats out the file fine, Id probably replace IO::Pipe with a routine that reads the file one line at a time. At least from what Ive read, that seems to be the desired effect.

      UPDATE
      BTW, when running this code on Cygwin, I get the following:
      ted@skywalkerii ~ $ perl client.pl 2006/03/08-02:31:02 CONNECT TCP Peer: "127.0.0.1:1245" Local: "127.0.0 +.1:8097" Use of uninitialized value in concatenation (.) or string at server.pl + line 23. Got: >Line = < #!/usr/bin/perl -w # client use strict; use IO::Socket::INET; my $sock = IO::Socket::INET->new(PeerHost => 'localhost', PeerPort => 8097, Proto => 'tcp', ); die "Unable to connect" unless $sock->connected(); while (my $receive = <$sock>) { print "Got: >$receive<\n"; }
      after copying client.pl to /home/ted/foo/client

      Ted
      --
      "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
        --Ralph Waldo Emerson
        You're still missing the point. :-)

        The 'cat' output is appearing on the stdout/stderr *of the server*, not in the client. The fact that the "Got:" is showing en empty string (well, just a newline, actually) indicates that nothing's getting from the server to the client. Instead, the Feeder object is failing (effectively) to do anything.

        By the way, I'm using 'cat' here as an example. The real application is running a much more complex command that's producing real output.

        As for reading from <$pipe>, that's exactly what it's trying to do. It's just stored $pipe inside $self and needs to extract it in order to read from it.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2022-05-21 06:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?