I have several years of Perl experience, especially with CGI scripts but also with Perl locally on my computer (some using Tk).

I'm interested in creating a client-server interface that can be used for internet-playable two-player games using Perl/Tk. To start with I'm working on a Tk-based Tic Tac Toe game, and while the game itself is no problem, I'm running into some trouble with the socket connections to get the Internet-playable part of it working.

After reading through Chapter 12 (Networking with Sockets) of Advanced Perl Programming and Chapter 22 (Internet and Socket Programming) of the Perl Black Book (by Steven Holzner) several times, I've got a pretty good idea of what the capabilities of the 'select' function and the IO::Socket and IO::Select modules are. I just can't seem to put together a working version of a client/server using them. I think I'm getting stuck on the logic, thinking event-driven is very different from usual Perl scripting.

Anyway, what I'm looking for is some examples of a way to write a server that can listen for new connections while letting Tk keep control of it's window, so that the Tk window doesn't freeze until it detects a new connection (i.e. it should be non-blocking and return control to Tk each time it checks, maybe called again using a Tk $widget->after($seconds, \&check_again); call? (or the $widget->repeat call rather than 'after')).

Once it accepts a connection, it needs to be able to continually be able to get incomming messages from the client for control and syncronzation...preferrably calling a subroutine with whatever the message contains as the argument each time a new message arrives.

The client needs to be similar, timing out in x (maybe 5) seconds if it can't connect, and once connected be able to act just like the previous server, accepting messages at random times and sending messages to the server.

How possible is this realistically? The main limitation is that it needs to be usable on Windows using ActiveState Perl v5.005_03 build 522, so forking isn't available.

I've spent hours reading and trying various ways, with no real success. If anyone could point me to an example somewhere that I've missed, or create an example, I would be very grateful! Hope I'm not asking too much...