Le 19/08/14 03:54, cpusoft a écrit :
> hi,
> i  use one machine as mina client to send message, but it has multiple
> network ip cards and  multiple ip address , and i have to specify one ip
> address as the client of mina,
>
> but, i do not find the funtion to specify the local ip address as the
> client of mina to send message ?  which function?

I'm not sure I understand what you need to do...

Why do you want to specify the IP address of your client? What service
needs it ?

In any case, you can use the connect method to provide your client
address using this method :

    public final ConnectFuture connect(SocketAddress remoteAddress,
SocketAddress localAddress,
            IoSessionInitializer<? extends ConnectFuture>
sessionInitializer) {

>
> my code is:
> public static void main(String[] args) {
>  NioSocketConnector connector = new NioSocketConnector();
> DefaultIoFilterChainBuilder chain = connector.getFilterChain();
>  ProtocolCodecFilter filter = new ProtocolCodecFilter(new
> ObjectSerializationCodecFactory());
> chain.addLast("objectFilter",filter);
>
> connector.getSessionConfig().setUseReadOperation(true);
> connector.setHandler(new ClientMinaServerHanlder());
>  connector.setConnectTimeoutCheckInterval(30);
> ConnectFuture cf = connector.connect(new
> InetSocketAddress("minaserverip",9988));
>  cf.awaitUninterruptibly();
>  cf.getSession().getCloseFuture().awaitUninterruptibly();
>  connector.dispose();
> }
>
> public class ClientMinaServerHanlder  extends IoHandlerAdapter{
>   @Override
>        public void sessionOpened(IoSession session) throws Exception {
> ....
> }
>  @Override
> public void sessionClosed(IoSession session) {
>             ....
> }
>
> @Override
> public void messageReceived(IoSession session, Object message)
> throws Exception {
>  ........
> }
> }
>
> plz help me ,thx
>

Reply via email to