如何确定MINA中的服务器端口
在我的应用程序中,我有一台监听多个 udp 端口的服务器。我在这个应用程序中使用了 MINA。
// code looks like this.
NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
...
...
acceptor.bind(new InetSocketAddress(9911));
acceptor.bind(new InetSocketAddress(9912));
现在在处理程序中,当我收到数据时,我有以下代码。
@Override
public void messageReceived(IoSession session, Object message)
throws Exception {
if (message instanceof IoBuffer) {
String msg = "data received in port "+ <NEED TO GET THE PORT NO>;
System.out.println(msg);
}
}
在代码中,我不知道如何获取接收数据的端口号(在本例中为 9911 或 9912)。
提前致谢。
in my application i have a server that listen in more than one udp port. i used MINA in this application.
// code looks like this.
NioDatagramAcceptor acceptor = new NioDatagramAcceptor();
...
...
acceptor.bind(new InetSocketAddress(9911));
acceptor.bind(new InetSocketAddress(9912));
now in handler when i receive the data i have following code.
@Override
public void messageReceived(IoSession session, Object message)
throws Exception {
if (message instanceof IoBuffer) {
String msg = "data received in port "+ <NEED TO GET THE PORT NO>;
System.out.println(msg);
}
}
in the code i have no idea how to get the port no ( 9911 or 9912 in this case) in which the data is received.
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参考: http://mina.apache .org/report/trunk/apidocs/org/apache/mina/core/session/IoSession.html
Reference: http://mina.apache.org/report/trunk/apidocs/org/apache/mina/core/session/IoSession.html