Let me try to explain.

1) I decided to use async socket. So, I have to work with the socket_handler
to decide on what to do next.
1.1) I did not want to do a busy wait - I wanted an event notification.
1.2) The implementation of jsss.ijs looks like a busy-wait to me.

2) My situation can be described as follows:
2.1) There is a client and server connected via async socket
2.2) There are a sequence of steps that need to be executed from the client.
However, each subsequent step on the client side depends on what is the
response from the server.

3) My proposal is to use three aspects
3.1) socket_handler invokes a list of verbs that needs to be executed on
receiving data
3.2) the verbs have to exit after performing part of the action and sending
a request to the server.
3.3) on invocation via the socket_handler, the verb has to continue to the
next step based on what was executed earlier and what response is received.

Thus, I want a multi-request-response based interaction coded in a single
verb.

4) The solution is to code the single verb as a state-machine and manage the
request-response cycles via state changes. This is what I have described
below.

5) The extension to multiple sockets can be done either via locales as in
jsss.ijs or by managing named buffers like in JWebServer/EventHandler

I hope my intention and goal are clear.

Regards,
Yuva



On Jan 3, 2008 1:17 AM, Oleg Kobchenko <[EMAIL PROTECTED]> wrote:

> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to