I'm not sure if there's a misunderstanding somewhere (which may be mine). As I understand it what you want to do is launch a command towards the server, and then another, and then another, all the time waiting for a response to one or more of your commands.
I suspect you're looking for something like this: http://www.perlmonks.org/?node_id=66135 In fact, it's specifically mentioned in the Perl Cookbook: http://docstore.mik.ua/orelly/perl/cookbook/ch07_15.htm Hope that helps put you on the right track. Regards, Carl On 29 August 2014 08:44, Chris Knipe <sav...@savage.za.org> wrote: > On Fri, Aug 29, 2014 at 1:18 AM, Sam <p...@net153.net> wrote: > > > Are you saying the normal 'unix' way won't work? (ie. listen on socket, > fork > > on an accepted connection, do the work, close) > > Not at all. My problem is not related to creating, accepting, or > forking at all. > > The block / waiting occurs whilst the socket is already connected. I > think a better way to describe this from terms I've seen whilst > googling... I need to be able to read & write simultaneously on the > socket after the client connected. > > Again, as per my example given, that is one single client socket > connected to the server. The asynchronous part comes in to the effect > that the client must be able to CONTINUOUSLY (non blocking) supply > commands to the server, whilst the server MAY take a large time before > responding to those commands. Now, every single (almost) perl > application I've looked at, does this to some form of degree in terms > of reading/writing on sockets... > > while (1) { > # read $_ from socket > # do stuff with $_ > # respond to client with some form of print > } > > In that example, whilst you are doing stuff with $_ (the workload, > sleep($randomtime) in my example, the client is blocked and the client > cannot write to the socket (or technically it can, but the server > can't process it rather). I am thus referring to the communication > stream, needing to be asynchronous. > > I don't even know how to accurately present this in text, but I'm > basically after something to the tune of the below. And the *real* > crux of the matter is going to be that the writing will indeed > sometimes happen at the *same time* as what the reading will happen. > Or at least, it needs to. > > while (1) { > # read $_ from the socket and pass it to some non blocking sub / event > handler > } > > sub processit { > # do stuff with $_ > # respond to the client with some form of print > } > > SMPP is a protocol which can be seen as a very good example. Whilst > it CAN work synchronously (receive data, process it, respond), it > operates immensely better when it's written as a asynchronous > application. THe same with certain aspects of NNTP for example (RFC > 4644), and I'm sure that there is allot of other examples I can give > where asynchronous communication is absolutely vital. > > I'm most certainly also not saying that it isn't possible with Perl > either. All that I am saying is that, to date, I have not been able > to find one single example, recipe, or cookbook entry on HOW to do > this. Not wanting to step on any toes, but I almost get the feeling > that the examples of code being given is rather outdated. > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >