Hello monks, I am trying to use the fileevent feature of Perl/Tk under Win32.
My test code is the following:
#!/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"; }
and it works fine under Mac/OS.
It does not work under Win32 (I tried Windows 2000 and Windows XP).
I used "nc" to send data to the listening socket and by looking at the
connections (by means of "netstat") it appears that the connection is
established.
However the fileevent is not triggered and the subroutine
"recedata" is never invoked.
I am using the latest available Perl for Win32 from ActiveState (5.8.4)
Can you provide any hint?

In reply to Tk fileevent with win32 sockets by massimo

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.