You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by 李健 <ji...@jit.com.cn> on 2007/06/20 03:07:40 UTC

How to use IoHandler in ClientSide

Hi,
 
    I'm developing my application with MINA1.1.0, It's working fine in ServerSide, But I'm confused by using IoHandler in ClientSide.
 
    I'll send R1 to the server and its response data is P1 and there will be R2-P2, R3-P3 etc. In the past time, I wrote code like this:
    
    byte[] request = ...;
    socketOutputStream.write(request);
    byte[] response = ...
    socketInputStream.read(response);
    ... // deal response data
 
    Now, for using MINA, I wrote code like this:
 
    ioConnector.bind(address, ioHandler);
    ... // get session
    session.write(request);
 
    The IoHandler which is binded to the ioConnector will deal response data, but I wanna to get the response data in my client class which sent the request data but not the IoHandler, so my client code can deal response data later after sent its request in one method process.(I'll use VMPipe sometimes, so i must using MINA IoConnector).
 
    who can give me some advice?
    can IoHandler pass the response data through the client class which sent the request data?
 
    Thanks.

Re: How to use IoHandler in ClientSide

Posted by 向秦贤 <fy...@gmail.com>.
Hi,
Try failed, gmail give me a fail notification.:)

Regards,

在 07-6-20,向秦贤<fy...@gmail.com> 写道:
> Hi,
> OK, I try it with "plain text". :)
>
> Regards,
>
> 在07-6-20,Emmanuel Lecharny <el...@gmail.com> 写道:
> > No, you don't get it :
> >
> > _all_ your mails are going through the moderator, because you are
> > using HTML (this is the way the ML is configured, I guess).
> >
> > If you are using Gmail, just switch to 'Plain text' so that your mail
> > will hit the list directly.
> >
> > Not sure this won't change your signature, though...
> >
> > It worth a try, anyway ;)
> >
> > Emmanuel
> >
> > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > Hi,
> > > yes, I do html docs. I just  use gmailer from firefox.
> > > No need accepting manually. I have done a jira item.
> > >
> > > Regards,
> > >
> > >
> > > 在07-6-20,Emmanuel Lecharny <el...@gmail.com> 写道:
> > > > Btw, are you sending mails as HTML docs ?
> > > >
> > > > because they are all moderated, and it's a little bit painfull, as we
> > > > have to accept them manually...
> > > >
> > > > Which mailer are you using ?
> > > >
> > > > Emmanuel
> > > >
> > > > On 6/20/07, 向秦贤 < fyaoxy@gmail.com> wrote:
> > > > > Hi,
> > > > > There are some little java files. I zipped that files, and post with
> > > mail.
> > > > > But apache take it as spam.
> > > > >
> > > > > Regards,
> > > > >
> > > > >
> > > > > 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> > > > > >
> > > > > > are you attaching the file?  Is it small enough to paste
> > > > > > inline?  Otherwise
> > > > > > maybe zip up the files and attach them.
> > > > > >
> > > > > >
> > > > > > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > > > > >
> > > > > > > Hi Lee,
> > > > > > > I want post a simple ftp example to the list, but gmail tell me
> > > apache
> > > > > > not
> > > > > > > want spam.
> > > > > > > Is there some other ways? should not JIRA, I think.
> > > > > > >
> > > > > > > Regards,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > 向秦贤
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > ..Cheers
> > > > > > Mark
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > 向秦贤
> > > > >
> > > > >
> > > > > --
> > > > > 向秦贤
> > > > >
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Cordialement,
> > > > Emmanuel Lécharny
> > > > www.iktek.com
> > > >
> > >
> > >
> > >
> > >  --
> > > 向秦贤
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
> >
>
>
>
> --
> 向秦贤
>
>


-- 
向秦贤

Re: How to use IoHandler in ClientSide

Posted by 向秦贤 <fy...@gmail.com>.
Hi,
yes, I do html docs. I just  use gmailer from firefox.
No need accepting manually. I have done a jira item.

Regards,


在07-6-20,Emmanuel Lecharny <el...@gmail.com> 写道:
>
> Btw, are you sending mails as HTML docs ?
>
> because they are all moderated, and it's a little bit painfull, as we
> have to accept them manually...
>
> Which mailer are you using ?
>
> Emmanuel
>
> On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > Hi,
> > There are some little java files. I zipped that files, and post with
> mail.
> > But apache take it as spam.
> >
> > Regards,
> >
> >
> > 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> > >
> > > are you attaching the file?  Is it small enough to paste
> > > inline?  Otherwise
> > > maybe zip up the files and attach them.
> > >
> > >
> > > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > >
> > > > Hi Lee,
> > > > I want post a simple ftp example to the list, but gmail tell me
> apache
> > > not
> > > > want spam.
> > > > Is there some other ways? should not JIRA, I think.
> > > >
> > > > Regards,
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > 向秦贤
> > > >
> > >
> > >
> > >
> > > --
> > > ..Cheers
> > > Mark
> > >
> >
> >
> >
> > --
> > 向秦贤
> >
> >
> > --
> > 向秦贤
> >
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>



-- 
向秦贤

Re: How to use IoHandler in ClientSide

Posted by Emmanuel Lecharny <el...@gmail.com>.
Btw, are you sending mails as HTML docs ?

because they are all moderated, and it's a little bit painfull, as we
have to accept them manually...

Which mailer are you using ?

Emmanuel

On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> Hi,
> There are some little java files. I zipped that files, and post with mail.
> But apache take it as spam.
>
> Regards,
>
>
> 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> >
> > are you attaching the file?  Is it small enough to paste
> > inline?  Otherwise
> > maybe zip up the files and attach them.
> >
> >
> > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > >
> > > Hi Lee,
> > > I want post a simple ftp example to the list, but gmail tell me apache
> > not
> > > want spam.
> > > Is there some other ways? should not JIRA, I think.
> > >
> > > Regards,
> > >
> > >
> > >
> > >
> > >
> > > --
> > > 向秦贤
> > >
> >
> >
> >
> > --
> > ..Cheers
> > Mark
> >
>
>
>
> --
> 向秦贤
>
>
> --
> 向秦贤
>


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

Re: How to use IoHandler in ClientSide

Posted by 向秦贤 <fy...@gmail.com>.
Hi,
gmail give us default encoding by mail from sender.
and we can just another utf-8 encoding.
seems to be good by creating a jira item.
haha:) it's a thing examining patient and patent.

Regards,

2007/6/20, Mark Webb <el...@gmail.com>:
>
> yep.  I was thinking gmail when I mentioned attachments.  I forgot this ML
> does not do attachments.  Good catch Emmanuel!
>
> On 6/20/07, Emmanuel Lecharny <el...@gmail.com> wrote:
> >
> > Ok,
> >
> > maybe the encoding scheme you are using (probably not US-ASCII) when
> > including your java code in your mail made them considered as spams.
> >
> > Can you try to change the encoding for your mail with the pasted code
> > to US-ASCII ?
> >
> > Attachements won't make their way to the ML, I'm afraid...
> >
> > If it does not work, then create a JIR with an Improvment status, and
> > attach your code.
> >
> > Emmanuel
> >
> > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > Hi,
> > > There are some little java files. I zipped that files, and post with
> > mail.
> > > But apache take it as spam.
> > >
> > > Regards,
> > >
> > >
> > > 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> > > >
> > > > are you attaching the file?  Is it small enough to paste
> > > > inline?  Otherwise
> > > > maybe zip up the files and attach them.
> > > >
> > > >
> > > > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > > >
> > > > > Hi Lee,
> > > > > I want post a simple ftp example to the list, but gmail tell me
> > apache
> > > > not
> > > > > want spam.
> > > > > Is there some other ways? should not JIRA, I think.
> > > > >
> > > > > Regards,
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > 向秦贤
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > ..Cheers
> > > > Mark
> > > >
> > >
> > >
> > >
> > > --
> > > 向秦贤
> > >
> > >
> > > --
> > > 向秦贤
> > >
> >
> >
> > --
> > Regards,
> > Cordialement,
> > Emmanuel Lécharny
> > www.iktek.com
> >
>
>
>
> --
> ..Cheers
> Mark
>



-- 
向秦贤

Re: How to use IoHandler in ClientSide

Posted by Mark Webb <el...@gmail.com>.
yep.  I was thinking gmail when I mentioned attachments.  I forgot this ML
does not do attachments.  Good catch Emmanuel!

On 6/20/07, Emmanuel Lecharny <el...@gmail.com> wrote:
>
> Ok,
>
> maybe the encoding scheme you are using (probably not US-ASCII) when
> including your java code in your mail made them considered as spams.
>
> Can you try to change the encoding for your mail with the pasted code
> to US-ASCII ?
>
> Attachements won't make their way to the ML, I'm afraid...
>
> If it does not work, then create a JIR with an Improvment status, and
> attach your code.
>
> Emmanuel
>
> On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > Hi,
> > There are some little java files. I zipped that files, and post with
> mail.
> > But apache take it as spam.
> >
> > Regards,
> >
> >
> > 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> > >
> > > are you attaching the file?  Is it small enough to paste
> > > inline?  Otherwise
> > > maybe zip up the files and attach them.
> > >
> > >
> > > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > > >
> > > > Hi Lee,
> > > > I want post a simple ftp example to the list, but gmail tell me
> apache
> > > not
> > > > want spam.
> > > > Is there some other ways? should not JIRA, I think.
> > > >
> > > > Regards,
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > 向秦贤
> > > >
> > >
> > >
> > >
> > > --
> > > ..Cheers
> > > Mark
> > >
> >
> >
> >
> > --
> > 向秦贤
> >
> >
> > --
> > 向秦贤
> >
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>



-- 
..Cheers
Mark

Re: How to use IoHandler in ClientSide

Posted by Emmanuel Lecharny <el...@gmail.com>.
Ok,

maybe the encoding scheme you are using (probably not US-ASCII) when
including your java code in your mail made them considered as spams.

Can you try to change the encoding for your mail with the pasted code
to US-ASCII ?

Attachements won't make their way to the ML, I'm afraid...

If it does not work, then create a JIR with an Improvment status, and
attach your code.

Emmanuel

On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> Hi,
> There are some little java files. I zipped that files, and post with mail.
> But apache take it as spam.
>
> Regards,
>
>
> 2007/6/20, Mark Webb < elihusmails@gmail.com>:
> >
> > are you attaching the file?  Is it small enough to paste
> > inline?  Otherwise
> > maybe zip up the files and attach them.
> >
> >
> > On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> > >
> > > Hi Lee,
> > > I want post a simple ftp example to the list, but gmail tell me apache
> > not
> > > want spam.
> > > Is there some other ways? should not JIRA, I think.
> > >
> > > Regards,
> > >
> > >
> > >
> > >
> > >
> > > --
> > > 向秦贤
> > >
> >
> >
> >
> > --
> > ..Cheers
> > Mark
> >
>
>
>
> --
> 向秦贤
>
>
> --
> 向秦贤
>


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

Fwd: How to use IoHandler in ClientSide

Posted by 向秦贤 <fy...@gmail.com>.
Hi,
There are some little java files. I zipped that files, and post with mail.
But apache take it as spam.

Regards,


2007/6/20, Mark Webb < elihusmails@gmail.com>:
>
> are you attaching the file?  Is it small enough to paste
> inline?  Otherwise
> maybe zip up the files and attach them.
>
>
> On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
> >
> > Hi Lee,
> > I want post a simple ftp example to the list, but gmail tell me apache
> not
> > want spam.
> > Is there some other ways? should not JIRA, I think.
> >
> > Regards,
> >
> >
> >
> >
> >
> > --
> > 向秦贤
> >
>
>
>
> --
> ..Cheers
> Mark
>



-- 
向秦贤


-- 
向秦贤

Re: How to use IoHandler in ClientSide

Posted by Mark Webb <el...@gmail.com>.
are you attaching the file?  Is it small enough to paste inline?  Otherwise
maybe zip up the files and attach them.


On 6/20/07, 向秦贤 <fy...@gmail.com> wrote:
>
> Hi Lee,
> I want post a simple ftp example to the list, but gmail tell me apache not
> want spam.
> Is there some other ways? should not JIRA, I think.
>
> Regards,
>
>
>
>
>
> --
> 向秦贤
>



-- 
..Cheers
Mark

Re: How to use IoHandler in ClientSide

Posted by 向秦贤 <fy...@gmail.com>.
Hi Lee,
I want post a simple ftp example to the list, but gmail tell me apache not
want spam.
Is there some other ways? should not JIRA, I think.

Regards,





-- 
向秦贤

Re: How to use IoHandler in ClientSide

Posted by Trustin Lee <tr...@gmail.com>.
Hi Brad,

On 6/20/07, Brad Harvey <ha...@gmail.com> wrote:
> Hi there,
>
> What you can do is put messages into a queue in your IO handler and read
> them out in your client class. This is a bit of a pain, so I had a go at
> a synchronous API that provides a closer client side programming model
> to what you're wanting to use - see the patch on
> https://issues.apache.org/jira/browse/DIRMINA-375.
>
> You could add the new classes in the patch into your own project
> (probably with a different package name so you don't get confused with
> real MINA classes) as no changes to existing MINA code are required.
>
> Note that in many cases implementing your processing logic in the IO
> Handler directly is better, but the synchronous send/receive approach is
> often easier for the simple request/response scenario you describe.

Thank you for posting the patch and examples.  I didn't have time to
review it deeply so far unfortunately.  It looks great looking from
the examples you provided though.  Please stay tuned; I will get back
to you definitely.

Thanks,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: How to use IoHandler in ClientSide

Posted by Brad Harvey <ha...@gmail.com>.
Hi there,

What you can do is put messages into a queue in your IO handler and read
them out in your client class. This is a bit of a pain, so I had a go at
a synchronous API that provides a closer client side programming model
to what you're wanting to use - see the patch on
https://issues.apache.org/jira/browse/DIRMINA-375.

You could add the new classes in the patch into your own project
(probably with a different package name so you don't get confused with
real MINA classes) as no changes to existing MINA code are required.

Note that in many cases implementing your processing logic in the IO
Handler directly is better, but the synchronous send/receive approach is
often easier for the simple request/response scenario you describe.

Hope that helps,
Brad


李健 wrote:
> Hi,
>  
>     I'm developing my application with MINA1.1.0, It's working fine in ServerSide, But I'm confused by using IoHandler in ClientSide.
>  
>     I'll send R1 to the server and its response data is P1 and there will be R2-P2, R3-P3 etc. In the past time, I wrote code like this:
>     
>     byte[] request = ...;
>     socketOutputStream.write(request);
>     byte[] response = ...
>     socketInputStream.read(response);
>     ... // deal response data
>  
>     Now, for using MINA, I wrote code like this:
>  
>     ioConnector.bind(address, ioHandler);
>     ... // get session
>     session.write(request);
>  
>     The IoHandler which is binded to the ioConnector will deal response data, but I wanna to get the response data in my client class which sent the request data but not the IoHandler, so my client code can deal response data later after sent its request in one method process.(I'll use VMPipe sometimes, so i must using MINA IoConnector).
>  
>     who can give me some advice?
>     can IoHandler pass the response data through the client class which sent the request data?
>  
>     Thanks.
>
>   

Re: How to use IoHandler in ClientSide

Posted by peter royal <pr...@apache.org>.
On Jun 26, 2007, at 12:46 AM, liquidchen wrote:
> So, is it true that for the current version, there are no easy way to
> implement a sync socket client??
> I have the same problem, for server side, it's work greate, but for  
> a sync
> client, it's seems helpless...

its possible, but requires work.  mina's model is that of a seda- 
style system and thus event driven. if you want to build some sync  
stuff on top, cool, or you can always just use regular java Sockets-n- 
stuff to do your client.

> is it possible to have a new feature for this kind of purpose in the
> furture, thanks a lot for this
> good framework...

sure, patches welcome!:)

-pete


-- 
proyal@apache.org - http://fotap.org/~osi




Re: How to use IoHandler in ClientSide

Posted by liquidchen <li...@gmail.com>.
So, is it true that for the current version, there are no easy way to
implement a sync socket client??
I have the same problem, for server side, it's work greate, but for a sync
client, it's seems helpless...
is it possible to have a new feature for this kind of purpose in the
furture, thanks a lot for this
good framework...

Mark Webb-4 wrote:
> 
> Although you are not using UDP, you can check out my UDP tutorial to get
> insight as to how this would be done.  Here is the link:
> http://mina.apache.org/udp-tutorial.html
> 
> On 6/19/07, 李健 <ji...@jit.com.cn> wrote:
>>
>> Hi,
>>
>>     I'm developing my application with MINA1.1.0, It's working fine in
>> ServerSide, But I'm confused by using IoHandler in ClientSide.
>>
>>     I'll send R1 to the server and its response data is P1 and there will
>> be R2-P2, R3-P3 etc. In the past time, I wrote code like this:
>>
>>     byte[] request = ...;
>>     socketOutputStream.write(request);
>>     byte[] response = ...
>>     socketInputStream.read(response);
>>     ... // deal response data
>>
>>     Now, for using MINA, I wrote code like this:
>>
>>     ioConnector.bind(address, ioHandler);
>>     ... // get session
>>     session.write(request);
>>
>>     The IoHandler which is binded to the ioConnector will deal response
>> data, but I wanna to get the response data in my client class which sent
>> the
>> request data but not the IoHandler, so my client code can deal response
>> data
>> later after sent its request in one method process.(I'll use VMPipe
>> sometimes, so i must using MINA IoConnector).
>>
>>     who can give me some advice?
>>     can IoHandler pass the response data through the client class which
>> sent the request data?
>>
>>     Thanks.
>>
> 
> 
> 
> -- 
> ..Cheers
> Mark
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-use-IoHandler-in-ClientSide-tf3949765.html#a11301287
Sent from the mina dev mailing list archive at Nabble.com.


Re: How to use IoHandler in ClientSide

Posted by Mark Webb <el...@gmail.com>.
Although you are not using UDP, you can check out my UDP tutorial to get
insight as to how this would be done.  Here is the link:
http://mina.apache.org/udp-tutorial.html

On 6/19/07, 李健 <ji...@jit.com.cn> wrote:
>
> Hi,
>
>     I'm developing my application with MINA1.1.0, It's working fine in
> ServerSide, But I'm confused by using IoHandler in ClientSide.
>
>     I'll send R1 to the server and its response data is P1 and there will
> be R2-P2, R3-P3 etc. In the past time, I wrote code like this:
>
>     byte[] request = ...;
>     socketOutputStream.write(request);
>     byte[] response = ...
>     socketInputStream.read(response);
>     ... // deal response data
>
>     Now, for using MINA, I wrote code like this:
>
>     ioConnector.bind(address, ioHandler);
>     ... // get session
>     session.write(request);
>
>     The IoHandler which is binded to the ioConnector will deal response
> data, but I wanna to get the response data in my client class which sent the
> request data but not the IoHandler, so my client code can deal response data
> later after sent its request in one method process.(I'll use VMPipe
> sometimes, so i must using MINA IoConnector).
>
>     who can give me some advice?
>     can IoHandler pass the response data through the client class which
> sent the request data?
>
>     Thanks.
>



-- 
..Cheers
Mark