see _bottom_ post ;-)

>  From: [EMAIL PROTECTED]
>  Subject: Re: Win32 and PERL::Tk and Sockets.....
>  Sent: Jan 04 '06 13:23
>  
>  >Otherwise it fills the textwidget with all the \n terminated
>  >strings it gets thru the port.
>  
>  I ran your code; the Tk window loads and a listener is created on
>  TCP/7890.  Though I am able to connect (telnet 127.0.0.1 7890) to the
>  server and I can type in the Tk text widget the input from the telnet
>  session isn't echo'd to the text widget, is this expected? Also, nothing
>  is echo'd to the telnet window until I disconnect (CTRL+]) the telnet
>  session.
>  
>  Thanks,
>  Brett Carroll
>  IT Specialist
>  Bureau of the Public Debt
>  (304)480-7731
>  [EMAIL PROTECTED]
>  
>  
>  "LYNN. RICKARDS" <[EMAIL PROTECTED]>
>  
>  01/03/2006 08:12 PM
>  
>  
>  To   [EMAIL PROTECTED]
>  
>  
>  cc   [email protected]
>  
>  
>  Subject      Re: Win32 and PERL::Tk and Sockets.....
>  
>  
>  [EMAIL PROTECTED] wrote:
>  >
>  > Has anyone heard of a fix or work-around for Sockets not working with
>  > PERL::Tk on Win32?
>  > I have found postings from several people that ran into the same
>  problem
>  > with Win32-Perl::Tk-Sockets, but haven't seen anything recently
>  relating
>  > to a fix.  The problem is that once the socket is opened (Listening)
>  the
>  > PERL::Tk GUI freezes while the socket listens for incoming data, but
>  > never unfreezes.
>  >
>  > I found a post, "Re: Sockets, fileevents and Win32" from June 19, 2000
>  > that was an apparent work-around and included a snippet of code, but
>  the
>  > code is incomplete and I have yet to be able to make it work.
>  >
>  > Thanks,
>  > Brett Carroll
>  >
>  >
>  
>  Perhaps POE will do it for you.
>  
>  The shamefully untidy code below was as very hastily hacked from
>  a POE example or a posting someplace, and serves as a debug tool
>  for PerlScript run within an app that grabs all the STD handles.
>  
>  There is a small leak somewhere...like if I forgetfully leave it sitting
>  idle overnight I have no resources in the morning. An extra cup of
>  coffee is a small price to pay ;-) I didn't touch it once it worked...
>  
>  Otherwise it fills the textwidget with all the \n terminated
>  strings it gets thru the port.
>  
>  HTH - Lynn.
>  #!/usr/bin/perl -w
>  
>  use Tk;
>  use Tk::StayOnTop;
>  use strict;
>  
>  use POE qw(Component::Server::TCP);
>  
>  
>  my $mw = $poe_main_window ;
>  my $t = $mw->Scrolled("Text", -width => 130, -height => 25, -wrap
>  => 'none');
>  $t->pack(-expand => 1);
>  $mw->stayOnTop;
>  
>  POE::Component::Server::TCP->new
>  ( Alias => "echo_server",
>  Port => 7890,
>  ClientInput => sub {
>  my ( $session, $heap, $input ) = @_[ SESSION, HEAP, ARG0 ];
>  print STDERR "$input $heap\n";
>  debugout ($t, $input . "\n");
>  }
>  );
>  
>  # Start the server.
>  $poe_kernel->run();
>  exit 0;
>  
>  sub debugout {
>  
>  my $widget  = shift;;
>  
>  my $ARG = shift;
>  $widget->insert('end', $ARG);
>  $widget->yview('end');
>  
>  } # end fill_text_widget
>  
>  

I never tried it with telnet..like I mentioned I use it to capture remote debug 
prints sent to
the socket from a script that is trapped in another app and cannot print to the
STD handles or use the perl /AS debugger. The relevant functions in that script 
should clarify..

$dbg = debugSetup() if($_DEBUG);

sub debugSetup
{
$host = "my_listening_host";
$port = "7890";

my $dbg = IO::Socket::INET->new(
        Proto => "tcp",
        PeerAddr => $host,
        PeerPort => $port,
        ) or die("cannot connect to port at $host");

print $dbg "Connection good\n";
return $dbg;
}

sub _debug
{
my $msg = shift;
return unless $dbg;
print $dbg $msg;
}


## USAGE:

_debug("DESC = $desc\n");

I would only guess telnet isn't terminating with newline?

 - Lynn.






_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to