Loading ...
Sorry, an error occurred while loading the content.

Re: [extremeperl] IO::Socket:INET Client problem

Expand Messages
  • Rob Nagler
    ... This isn t the right list for this type of question, but I ll respond anyway: while (sysread($socket, $element, 8192)) { print STDOUT $element; } The
    Message 1 of 4 , Dec 23, 2002
    View Source
    • 0 Attachment
      "diarmuid_obriain <diarmuid_obriain@...>" <diarmuid_obriain@...> writes:
      > while ($element = <$socket>) {
      > print STDOUT "$element";
      > }

      This isn't the right list for this type of question, but I'll respond
      anyway:

      while (sysread($socket, $element, 8192)) {
      print STDOUT $element;
      }

      The readline (<>) function stops reading a \n. There's no way around
      this by definition.

      Try http://www.perlmonks.org for questions like this in the future.

      Cheers,
      Rob
    • diarmuid_obriain <diarmuid_obriain@3com.
      Rob, Thanks, I tried this but it still doesn t work. Diarmuid
      Message 2 of 4 , Dec 23, 2002
      View Source
      • 0 Attachment
        Rob,

        Thanks,

        I tried this but it still doesn't work.

        Diarmuid
      • Tom Brown
        I think Rob s answer was backwards... e.g. the read side of things, not the write (print) side of things, but it isn t very clear where the problem lies. His
        Message 3 of 4 , Dec 23, 2002
        View Source
        • 0 Attachment
          I think Rob's answer was backwards... e.g. the read side of things, not
          the write (print) side of things, but it isn't very clear where
          the problem lies. His answer is quite correct <> isn't the normal
          way to grab data from a socket... it is meant for line oriented
          input...

          I think you're just looking for

          my $old = select $socket;
          $| = 1;
          select $old;

          which changes the filehandle to no longer be buffered. You may
          need to run it for STDOUT too.

          -Tom



          On Mon, 23 Dec 2002, diarmuid_obriain <diarmuid_obriain@...> wrote:

          > I have a problem with a TCP Client I am working with. It works fine
          > if the data on the server that is being sent to the socket has
          > a '\r\n' at the end of the line however if it does not then that line
          > is not printed until after the next \r\n action. This basically makes
          > it impossible for the client to see a command prompt from the server
          > which would naturally not have the \r\n at the end of the line. Is
          > there any way in Perl of forcing the client to print the contents of
          > the buffer without waiting for the \r\n sequence.
        Your message has been successfully submitted and would be delivered to recipients shortly.