You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by daniel vettori <da...@gmail.com> on 2012/11/05 11:37:38 UTC

synchronous client and sever socket messaging

Hi,

As i am using Apace MINA in my socket component. I want to have synchronous
behaviour with the socket server and socket client while sending messages.
Right now ,I send messages directly and process based on delimiter. Is it
good to have some kind of Ack thing to work with...or work with multiple
sessions at a time.. or any other.What will be the right way to approach
for this ...??

Thanks

Daniel

Re: synchronous client and sever socket messaging

Posted by Mike van Goor <mi...@probie.nl>.
Hi,

Another way would be to temporary remove the OP_READ from the other 
socketchannels on the selector.
I am not sure if this is supported by MINA to be honoust.

Like Emmanuel stated there is no way to stop a client from sending data 
to the server. The above method will only stop MINA from reading the 
buffers untill you set the interest back on the selector.

Regards,
Mike

Op 5-11-2012 16:55, Emmanuel Lécharny schreef:
> Le 11/5/12 4:17 PM, daniel vettori a écrit :
>> suppose three clients and one server are there....now one client connects
>> to server..and at that time, dont want other two clients to interact with
>> socket server untill the processing of message based on delimiter get
>> over
>> between server and the first client.......
> There is nothing you can do on the server to forbid a client to actually
> send some message to the server. This is a server...
>
> What you can do is to send a message to all the clients telling them
> that they should not send a message until the server send a ack to them,
> assumin the clients *will* respect this information. Again, this is all
> related to the protocol you define, it has nothing to do with the MINA
> API or whatever IO.
>
> This is really a bizare requirement...
>
>

Re: synchronous client and sever socket messaging

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 11/5/12 4:17 PM, daniel vettori a écrit :
> suppose three clients and one server are there....now one client connects
> to server..and at that time, dont want other two clients to interact with
> socket server untill the processing of message based on delimiter get over
> between server and the first client.......
There is nothing you can do on the server to forbid a client to actually 
send some message to the server. This is a server...

What you can do is to send a message to all the clients telling them 
that they should not send a message until the server send a ack to them, 
assumin the clients *will* respect this information. Again, this is all 
related to the protocol you define, it has nothing to do with the MINA 
API or whatever IO.

This is really a bizare requirement...


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: synchronous client and sever socket messaging

Posted by daniel vettori <da...@gmail.com>.
suppose three clients and one server are there....now one client connects
to server..and at that time, dont want other two clients to interact with
socket server untill the processing of message based on delimiter get over
between server and the first client.......

Re: synchronous client and sever socket messaging

Posted by Dhruv Chopra <dh...@shephertz.co.in>.
If you are trying to build an ACK mechanism just for ordered delivery -
then you don't need to do anything special as TCP sessions are by nature
ordered and do all the sequencing for you.
Also can you describe why you are using delimiters? If your problem is that
you are receiving multiple small messages sent from the client in a single
messageReceived on the server - then you can try turning off Nagle from the
client when connection is made and see if that helps.
If however you really need an ACK - then like Emmanuel mentioned, you will
need to define your own protocol on top of TCP for such custom behavior.

On Mon, Nov 5, 2012 at 6:00 PM, daniel vettori
<da...@gmail.com>wrote:

> On Mon, Nov 5, 2012 at 4:35 PM, Emmanuel Lécharny <elecharny@gmail.com
> >wrote:
>
> > Le 11/5/12 11:37 AM, daniel vettori a écrit :
> >
> >  Hi,
> >>
> >> As i am using Apace MINA in my socket component. I want to have
> >> synchronous
> >> behaviour with the socket server and socket client while sending
> messages.
> >> Right now ,I send messages directly and process based on delimiter. Is
> it
> >> good to have some kind of Ack thing to work with...or work with multiple
> >> sessions at a time.. or any other.What will be the right way to approach
> >> for this ...??
> >>
> >
> > It's up to you to define a protocol that expect some kind of ACKs.
> >
> > Otherwise, I'm not sure what you are trying to do : how does working with
> > multiple sessions relates to the problem you are trying to fix ?
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
>
>
>
>
> What i want is...suppose 2 msgs are there to be send ...i want second msg
> to be sent only when ack for first msg is received...or with every
> session..... !!! ???
>

Re: synchronous client and sever socket messaging

Posted by Bernd Fondermann <be...@gmail.com>.
On Thu, Nov 8, 2012 at 7:55 AM, daniel vettori
<da...@gmail.com> wrote:
> Thanks ...for zookeeper......one more  small problem is ...in this case one
> client and one server. i send one message from client to server with some
> properties .then i dont want second message to be sent to server till i
> received the reply from server(reply is some message after
> delimitation)..the problem is coming in present scenerio is i attach some
> properties with message (from client) and want the replied messsage and
> attach that same properties(that i'l store in session) for furthur use.
> rigt ow i m trying session.suspendwrite() and resume things.....dont want
> the second message to cliet till first reply from server.  how do i
> approach?

If this is a Zookeeper question, you'll get the best support over on
their lists.

  Bernd

Re: synchronous client and sever socket messaging

Posted by daniel vettori <da...@gmail.com>.
Thanks ...for zookeeper......one more  small problem is ...in this case one
client and one server. i send one message from client to server with some
properties .then i dont want second message to be sent to server till i
received the reply from server(reply is some message after
delimitation)..the problem is coming in present scenerio is i attach some
properties with message (from client) and want the replied messsage and
attach that same properties(that i'l store in session) for furthur use.
rigt ow i m trying session.suspendwrite() and resume things.....dont want
the second message to cliet till first reply from server.  how do i
approach?

Thanks

Re: synchronous client and sever socket messaging

Posted by Bernd Fondermann <bf...@brainlounge.de>.
On 05.11.12 13:30, daniel vettori wrote:
>
> What i want is...suppose 2 msgs are there to be send ...i want second msg
> to be sent only when ack for first msg is received...or with every
> session..... !!! ???

What you want looks like a distributed semaphore or universal ordering 
of messages.
Try Apache Zookeeper.

   Bernd


Re: synchronous client and sever socket messaging

Posted by daniel vettori <da...@gmail.com>.
On Mon, Nov 5, 2012 at 4:35 PM, Emmanuel Lécharny <el...@gmail.com>wrote:

> Le 11/5/12 11:37 AM, daniel vettori a écrit :
>
>  Hi,
>>
>> As i am using Apace MINA in my socket component. I want to have
>> synchronous
>> behaviour with the socket server and socket client while sending messages.
>> Right now ,I send messages directly and process based on delimiter. Is it
>> good to have some kind of Ack thing to work with...or work with multiple
>> sessions at a time.. or any other.What will be the right way to approach
>> for this ...??
>>
>
> It's up to you to define a protocol that expect some kind of ACKs.
>
> Otherwise, I'm not sure what you are trying to do : how does working with
> multiple sessions relates to the problem you are trying to fix ?
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com




What i want is...suppose 2 msgs are there to be send ...i want second msg
to be sent only when ack for first msg is received...or with every
session..... !!! ???

Re: synchronous client and sever socket messaging

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 11/5/12 11:37 AM, daniel vettori a écrit :
> Hi,
>
> As i am using Apace MINA in my socket component. I want to have synchronous
> behaviour with the socket server and socket client while sending messages.
> Right now ,I send messages directly and process based on delimiter. Is it
> good to have some kind of Ack thing to work with...or work with multiple
> sessions at a time.. or any other.What will be the right way to approach
> for this ...??

It's up to you to define a protocol that expect some kind of ACKs.

Otherwise, I'm not sure what you are trying to do : how does working 
with multiple sessions relates to the problem you are trying to fix ?


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com