问题!用Mina自带的客户端写,数据发送不出去?
package com.example.demo;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.NioDatagramConnector;
public class MinaClientTest {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
NioDatagramConnector connector = new NioDatagramConnector();
connector.setHandler(new MyMinaClientHandler());
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory()));
ConnectFuture future = connector.connect(new InetSocketAddress(InetAddress.getLocalHost(), 8989));
future.awaitUninterruptibly();
System.out.println("InetAddress.getLocalHost() :"+InetAddress.getLocalHost());
IoSession session = future.getSession();
// writeToServer(session);
BufferedReader bf = null;
bf = new BufferedReader(new InputStreamReader(System.in));
String line =null;
while(!(line=bf.readLine()).equals("bye")){
System.out.println(line);
session.write(line);
}
bf.close();
}
}问题!用Mina自带的客户端写,数据发送不出去?

