It's not clear what this pattern is for, what is the goal.
A very simple generic multi-socket example is done in "Pump"
http://www.jsoftware.com/jwiki/Scripts/Pump
For executing J verbs, there is already "jsss"
j601\system\classes\cs\jsss.ijs
j601\system\classes\cs\jsss_demo.ijs
Both don't use async sockets. We have not established
the benefit of async yet either.
--- Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Assuming that the issue of getting all the data in the socket is solved, I
> find a state-machine pattern helpful. The pattern is as follows:
>
> [State-Machine-Pattern-For-Async-Socket-Coordination]
>
> Context: One verb to coordinate multiple send-receive communications over a
> async socket.
>
> Description:
> 1) Arrange the verb that coordinates the communication as a state machine.
> Simple implementation is using a select. control structure. The state can be
> maintained as a global variable or at socket level buffer.
> 2) Ensure that each state transition ends with a state change and a send
> message.
> 3) Add the verb to the socket-handler as a command-chain. On change of state
> to a socket-ready-for-read, the data is read and passed to the verb for
> execution.
> 4) The verb thus "wakes-up" and continues the send-receive sequence based on
> the state information previously stored.
> 5) Bookkeeping with regard to state, addition and removal of verb in the
> socket handler command chain completes the implementation
>
> Other implementations: I have seen this pattern in libwww where the protocol
> is implemented as a state-machine.
>
> Regards,
> Yuva
>
>
>
> On Dec 21, 2007 3:54 PM, Yuvaraj Athur Raghuvir <[EMAIL PROTECTED]>
> wrote:
>
> > Hello,
> >
> > a) I have a socket_handler associated with a async socket
> > b) I have a test verb that performs a series of communication calls -
> > sends data, receives data, and decides on the next step based on data
> > returned.
> > c) The problem I face is that the execution of the next statement in the
> > verb occurs before the data in the socket is read.
> >
> > Q: How to synchronize verb execution with socket communication when I use
> > async mode on socket?
> >
> > Regards,
> > Yuva
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm