You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by ci...@gmail.com on 2006/07/07 17:49:02 UTC

SocketConnector object utilization

Hi all,

Does
 SocketConnector connector = new SocketConnector(); connector.connect( 
                new InetSocketAddress( "localhost",
                Integer.parseInt( 54321 ) ),
                new MyProtocolHandler() );Uses MyProtocolHandler() from a pre used cache?I have an application that transmit images to a server.Each images are not sent via bulk and are sent independently,Because of that, i would need to create a new MyProtocolHandler() instance for every connection.Would there be a better implementation for this?

Re: SocketConnector object utilization

Posted by Trustin Lee <tr...@gmail.com>.
On 7/8/06, peter royal <pr...@apache.org> wrote:
>
> On Jul 7, 2006, at 12:16 PM, <ci...@gmail.com> <ci...@gmail.com>
> wrote:
> > Is there a way for me produce an IoAcceptor behaviour on the client
> > side? A shared across IoHandler for connectors (of course with
> > different sessions).
>
> sure, just pass the same IoHandler instance in each time you
> call .connect() :)


Exactly.  BTW we cannot assume that we will call connect() just once, so the
IoHandler implementation shouldn't assume it is handling only one
connection.  For convenience, an implementor could use
org.apache.mina.handler.multiton package.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: [VOTE] SocketConnector object utilization

Posted by Trustin Lee <tr...@gmail.com>.
On 3/14/07, Coding Horse <zh...@hotmail.com> wrote:
>
>
> Was the API changed in mina 2.0?  So one has to use connector.setHandler
> (...)
> instead of passing the handler to .connect() ?  thx.


Yep. :)

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

Re: [VOTE] SocketConnector object utilization

Posted by Coding Horse <zh...@hotmail.com>.
Was the API changed in mina 2.0?  So one has to use connector.setHandler(...)
instead of passing the handler to .connect() ?  thx.


peter royal wrote:
> 
> On Jul 7, 2006, at 12:16 PM, <ci...@gmail.com> <ci...@gmail.com>  
> wrote:
>> Is there a way for me produce an IoAcceptor behaviour on the client  
>> side? A shared across IoHandler for connectors (of course with  
>> different sessions).
> 
> sure, just pass the same IoHandler instance in each time you  
> call .connect() :)
> 
> -pete
> 
>>
>> ----- Original Message ----- From: "peter royal" <pr...@apache.org>
>> To: <mi...@directory.apache.org>
>> Sent: Friday, July 07, 2006 11:53 PM
>> Subject: Re: SocketConnector object utilization
>>
>>
>>> On Jul 7, 2006, at 11:49 AM, <ci...@gmail.com>  
>>> <ci...@gmail.com> wrote:
>>>> Does
>>>>  SocketConnector connector = new SocketConnector();  
>>>> connector.connect(
>>>>                 new InetSocketAddress( "localhost",
>>>>                 Integer.parseInt( 54321 ) ),
>>>>                 new MyProtocolHandler() );Uses MyProtocolHandler 
>>>> ()  from a pre used cache?I have an application that transmit  
>>>> images to  a server.Each images are not sent via bulk and are  
>>>> sent independently,Because of that, i would need to create a new  
>>>> MyProtocolHandler() instance for every connection.Would there be  
>>>> a better implementation for this?
>>>
>>> For the connector side, the IoHandler that you pass in is for  
>>> just  that one connection.
>>>
>>> This is opposite from the IoAcceptor side.. It takes an  
>>> IoHandler,  but it is shared amongst all connections accepted.
>>>
>>> In this situation, you will get the behavior that you want.
>>>
>>> -pete
>>>
>>>
>>> -- 
>>> proyal@apache.org - http://fotap.org/~osi
>>>
>>>
>>>
>>
>>
>>
> 
> 
> -- 
> proyal@apache.org - http://fotap.org/~osi
> 
> 
> 
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/SocketConnector-object-utilization-tf2697131.html#a9462115
Sent from the mina dev mailing list archive at Nabble.com.


Re: SocketConnector object utilization

Posted by peter royal <pr...@apache.org>.
On Jul 7, 2006, at 12:16 PM, <ci...@gmail.com> <ci...@gmail.com>  
wrote:
> Is there a way for me produce an IoAcceptor behaviour on the client  
> side? A shared across IoHandler for connectors (of course with  
> different sessions).

sure, just pass the same IoHandler instance in each time you  
call .connect() :)

-pete

>
> ----- Original Message ----- From: "peter royal" <pr...@apache.org>
> To: <mi...@directory.apache.org>
> Sent: Friday, July 07, 2006 11:53 PM
> Subject: Re: SocketConnector object utilization
>
>
>> On Jul 7, 2006, at 11:49 AM, <ci...@gmail.com>  
>> <ci...@gmail.com> wrote:
>>> Does
>>>  SocketConnector connector = new SocketConnector();  
>>> connector.connect(
>>>                 new InetSocketAddress( "localhost",
>>>                 Integer.parseInt( 54321 ) ),
>>>                 new MyProtocolHandler() );Uses MyProtocolHandler 
>>> ()  from a pre used cache?I have an application that transmit  
>>> images to  a server.Each images are not sent via bulk and are  
>>> sent independently,Because of that, i would need to create a new  
>>> MyProtocolHandler() instance for every connection.Would there be  
>>> a better implementation for this?
>>
>> For the connector side, the IoHandler that you pass in is for  
>> just  that one connection.
>>
>> This is opposite from the IoAcceptor side.. It takes an  
>> IoHandler,  but it is shared amongst all connections accepted.
>>
>> In this situation, you will get the behavior that you want.
>>
>> -pete
>>
>>
>> -- 
>> proyal@apache.org - http://fotap.org/~osi
>>
>>
>>
>
>
>


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




Re: SocketConnector object utilization

Posted by ci...@gmail.com.
Is there a way for me produce an IoAcceptor behaviour on the client side? A 
shared across IoHandler for connectors (of course with different sessions).

----- Original Message ----- 
From: "peter royal" <pr...@apache.org>
To: <mi...@directory.apache.org>
Sent: Friday, July 07, 2006 11:53 PM
Subject: Re: SocketConnector object utilization


> On Jul 7, 2006, at 11:49 AM, <ci...@gmail.com> <ci...@gmail.com> 
> wrote:
>> Does
>>  SocketConnector connector = new SocketConnector(); connector.connect(
>>                 new InetSocketAddress( "localhost",
>>                 Integer.parseInt( 54321 ) ),
>>                 new MyProtocolHandler() );Uses MyProtocolHandler()  from 
>> a pre used cache?I have an application that transmit images to  a 
>> server.Each images are not sent via bulk and are sent 
>> independently,Because of that, i would need to create a new 
>> MyProtocolHandler() instance for every connection.Would there be a 
>> better implementation for this?
>
> For the connector side, the IoHandler that you pass in is for just  that 
> one connection.
>
> This is opposite from the IoAcceptor side.. It takes an IoHandler,  but it 
> is shared amongst all connections accepted.
>
> In this situation, you will get the behavior that you want.
>
> -pete
>
>
> -- 
> proyal@apache.org - http://fotap.org/~osi
>
>
>
> 


Re: SocketConnector object utilization

Posted by peter royal <pr...@apache.org>.
On Jul 7, 2006, at 11:49 AM, <ci...@gmail.com> <ci...@gmail.com>  
wrote:
> Does
>  SocketConnector connector = new SocketConnector(); connector.connect(
>                 new InetSocketAddress( "localhost",
>                 Integer.parseInt( 54321 ) ),
>                 new MyProtocolHandler() );Uses MyProtocolHandler()  
> from a pre used cache?I have an application that transmit images to  
> a server.Each images are not sent via bulk and are sent  
> independently,Because of that, i would need to create a new  
> MyProtocolHandler() instance for every connection.Would there be a  
> better implementation for this?

For the connector side, the IoHandler that you pass in is for just  
that one connection.

This is opposite from the IoAcceptor side.. It takes an IoHandler,  
but it is shared amongst all connections accepted.

In this situation, you will get the behavior that you want.

-pete


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