in reply to Re^2: Server with GUI
in thread Server with GUI
You may have a Window's related problem, where Tk's fileevent dosn't work reliably on some version of windows. See Client/Server sockets with TK on Win32 .
There are workarounds, see Another Win32 Tk fileevent work around : using ioctl() properly for instance. If that dosn't work for you, it's possible to use a conventional select loop with sysread in a separate subroutine, and call it with a Tk timer every 10 milliseconds. See Tk fileevent with win32 sockets for a timer solution.
It goes something like this untested code:
... other Tk code my $timer = $mw->repeat(10, \&read_it ); MainLoop; sub read_it{ my $client = $listen->accept or die "Accept failed: $!"; if( IO::Select->new($client)->can_read(5) ) { sysread( $client, $_, 1 ) and print; } else { print "Timeout\n"; } close $client; }
Also see Mastering Perl/Tk and the Window's fileevent problem
If you are an eager seeker of Perl knowledge, I will tell you that another, more advanced GUI toolkit, called Gtk2 does have an IO watch ( like fileevent ) which does work on Windows, see Simple threaded chat server for a simple example to test with.
Finally, you could just put Ubuntu Linux on your Desktop with a dual boot to Windows. :-)
Finally, just to get you banging your head against the wall, I found an example of Wx using sockets, see Wx Socket. It probably works on Windows.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Server with GUI
by gg4000 (Novice) on May 30, 2012 at 16:16 UTC | |
|
Re^4: Server with GUI
by gg4000 (Novice) on Jun 01, 2012 at 23:46 UTC | |
by zentara (Cardinal) on Jun 02, 2012 at 10:28 UTC | |
by gg4000 (Novice) on Jun 02, 2012 at 22:38 UTC | |
by zentara (Cardinal) on Jun 03, 2012 at 09:42 UTC | |
by gg4000 (Novice) on Jun 03, 2012 at 09:57 UTC | |
|