如题,请问mina框架是否支持发送udp广播包,以下面代码发送,会提示服务器异常。
// 创建一个tcp/ip 连接
//创建客户端连接器
Log.i("TAG","正在创建Socket连接!");
Log.i("TAG","PORT:"+PORT+",HostName:"+hostName);
NioDatagramConnector connector=new NioDatagramConnector();
/*---------接收字符串---------*/
// //创建接收数据的过滤器
DefaultIoFilterChainBuilder chain = connector.getFilterChain();
// 设定这个过滤器将一行一行(/r/n)的读取数据
//chain.addLast("myChin", new ProtocolCodecFilter(
// new TextLineCodecFactory()));
/*---------接收对象---------*/
// 创建接收数据的过滤器
// 创建接收数据的过滤器
chain.addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8")
//,
//LineDelimiter.WINDOWS.getValue(),
//LineDelimiter.WINDOWS.getValue()
)));
//设置日志记录器
//chain.addLast("Logger", new LoggingFilter());
//设置连接超时检查时间
connector.setConnectTimeoutCheckInterval(10000);
//设置事件处理器
connector.setHandler(new ClientHandler(this.myHandler));
//建立连接
Log.i("TAG","开始建立连接!");
cf=connector.connect(new InetSocketAddress(
hostName,PORT));
cf.addListener(new IoFutureListener(){
@Override
public void operationComplete(IoFuture future) {
// TODO Auto-generated method stub
ConnectFuture connFuture = (ConnectFuture) future;
if (connFuture.isConnected()) {
session = future.getSession();
try {
sendData();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
Log.i("TAG","not connect");
}
}
});
其中hostname是“255.255.255.255”,port是9999