spx2 has asked for the wisdom of the Perl Monks concerning the following question:

hi im planning on building a one-to-one chat application
it sounds very simple.but i have to cope with the
fact that im having perl 5.8.0 on windows and it seems
that fork() is not properly offering a context for
parallel programming,tough i would have expected it
to do so.
what can i use to be able to parallel program?
this question is related to the difficulty im finding
in the following:
when one of the ends is receiving something it must also
write but in a perl console one can do one of two things:
1)wait for user input and you are not able to print anything
2)print on the screen but do not take user input
the problem is i need both of these at the same time.
also i would like to not start building from scratch
a perl library for console
i find ncurses\curses to be a nice one but it seems ppm
does not find it through its packages
is POE an alternative to threads ? is it good enough?
does it have graphics functions to make a simple GUI?
all suggestions are welcomed
  • Comment on poe/win32/fork/threads chat-application

Replies are listed 'Best First'.
Re: poe/win32/fork/threads chat-application
by jczeus (Monk) on May 15, 2007 at 06:36 UTC
    POE is fantastic for doing these sort of things. It has a steep learning curve, however. I can recommend the chapter on POE in "Advanced Perl Programming" by Simon Cozens (O'Reilly). But once you got the hang of it, it's much easier to write parallel/long-running applications with it compared to fork() or threads. POE by itself has no GUI, but you can replace its own main loop by the main loop of (G)Tk, for example.
Re: poe/win32/fork/threads chat-application
by zentara (Cardinal) on May 15, 2007 at 12:30 UTC
    If you want a simple GUI on Windows, I suggest Tk. Tk contains an "event-loop" so it can be used like POE. Here is a Tk client-server example. Start the server, then as many clients as you want. If you notice, there is a a separate entry box at the bottom of the client, so you can receive and send simultaneously. There are many, many variations on this type of example. The big distinction ( as you will learn as you delve into sockets) is that IO::Select uses a blocking mode. That is, for short messages it is fine, but if you transfer huge files, it will block others until the file transfer is complete. In those cases you want a forking or threaded server. Search for examples of them. For instance Sockets-File-Upload with Net::EasyTCP which uses the very handy Net::EasyTCP module.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: poe/win32/fork/threads chat-application
by Moron (Curate) on May 15, 2007 at 11:08 UTC
    I'm not a Windows person, but I've noticed that there's a start command available in Windows for spawning a process - by default without wait. The two processes can communicate using Win32::Pipe - in the documentation mentally translate "server" into "parent" and "client" into "child" for your case.
    __________________________________________________________________________________

    ^M Free your mind!

      n the documentation mentally translate "server" into "parent" and "client" into "child" for your case.

      ... and it won't work. To understand why it won't work you'll have to try it. Oh, but your " not a Windows person". That explains a lot.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I am sure the community would benefit from your explanation rather than just your conclusion (if you should have time?) - I got the idea of using Win32::Pipe from the big camel book chapter 16 - and I can't try it out at work because I am hired as a unix programmer and have a paranoically restrictive PC environment to contend with.
        __________________________________________________________________________________

        ^M Free your mind!

Re: poe/win32/fork/threads chat-application
by BrowserUk (Patriarch) on May 15, 2007 at 13:39 UTC