in reply to non-blocking TCP/IP client object using callbacks

As far as I understand your question you want to write a client server application where the client is actually the telnet program (very thin client) so the server is a console TCP daemon. Since the server is supposed to serve more then one client you need to have a mechanism for parallel request processing. Or perhaps you don't? Are you sure you need that? Can't the requests just wait in a queue? If you really need to process the requests in parallel you can achieve this in a few ways: I hope this will help you to choose the architecture.
  • Comment on Re: non-blocking TCP/IP client object using callbacks

Replies are listed 'Best First'.
Re: Re: non-blocking TCP/IP client object using callbacks
by jettero (Monsignor) on Jul 22, 2003 at 12:10 UTC

    See, this is why I shoulda studied more in english. I fail to make myself clear every time...

    I wish to use Net::Telnet or IO::Sockets actually. And I'm connecting to a remote server, so inetd doesn't really apply. But I don't wish for control to remain stuck in the module...

    When my module receives messages, it should pass them to the actual application via callbacks.

    POE is really neat looking! I hadn't seen that before, but it's probably a bad fit for a telnet client object.

      Actually, POE should work just great as a telnet client. Here's an example of a simple "port scanner" that shows how easy it is to make a TCP client with POE::Component::Client::TCP. There are a lot more useful examples at the POE Cookbook. Also, since POE is event based it will do exactly what you were wanting as far as passing the messages to whatever subroutine you want via callback.

      It may take a little while to get used to writing programs with POE, but I highly recommend it! It is much simpler than threads and you don't have to worry about IPC like you would with forking because it's all the same process.

        Yes, ... I forced myself to go read more about this POE. At first it looked like just the Latest Thing, but after further reading ...

        I think poe::component::client::tcp precisely what I was asking about without knowing how to ask about it. I'm going to try it out and see if it's really what I was hoping for.

        update: It LOOKED like what I wanted, but I can't figure out how to call _both_ the MainLoop for Curses::UI AND the run() for the POE object...

        I'm convinced there's a way to do it... but I don't yet see it.

        update: No. This is wrong. It could possibly be made to work, but it's giant, speaks it's own language, and doesn't really do what I want at all. Now I'm back to square one... I may not use IPC::SysV though. There's a lot of stuff on the perlipc manpage.