massimo has asked for the wisdom of the Perl Monks concerning the following question:
and it works fine under Mac/OS.#!/usr/bin/perl use strict; use Tk; use IO; use IO::Socket::INET; my ($server, $server_port, $maxlisten); $maxlisten=5; if (@ARGV<1) { $server_port=9876; } else { $server_port=shift; } $server = IO::Socket::INET->new(LocalPort => $server_port, Type => SOCK_STREAM, Reuse => 1, Listen => $maxlisten ); my $top = MainWindow->new(); $top->fileevent($server, 'readable' => \&recedata); MainLoop(); sub recedata { warn "in recedata\n"; my $data; my $n=80; my $client=$server->accept(); if(sysread($client,$data,$n)<0) { die "Error in socket read\n"; } print "$data\n"; # my $data=<$client>; my $t2 = $top->Scrolled('Text'); $t2->pack(-expand => 1, -fill => 'both'); tie (*TEXT2, 'Tk::Text',$t2); print TEXT2 "$data\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk fileevent with win32 sockets
by keszler (Priest) on Aug 16, 2004 at 20:13 UTC | |
by massimo (Initiate) on Aug 17, 2004 at 07:59 UTC | |
|
Re: Tk fileevent with win32 sockets
by ikegami (Patriarch) on Aug 16, 2004 at 17:07 UTC | |
by eserte (Deacon) on Aug 16, 2004 at 17:13 UTC | |
by Ven'Tatsu (Deacon) on Aug 16, 2004 at 18:36 UTC |