gpt4 book ai didi

client - Apache Mina 中的服务器

转载 作者:行者123 更新时间:2023-12-01 11:57:30 26 4
gpt4 key购买 nike

我在这个链接 http://www.techbrainwave.com/?p=912 上找到了一些代码其中描述了如何使用 apache mina 设置客户端服务器架构。但是,在提供的示例中,它只是单向通信(从客户端到服务器)。有谁知道如何修改它以获得双向通信?

最佳答案

如果想让服务端回复客户端消息,需要在服务端的IoHandler中进行:

@Override
public void messageReceived(IoSession session, Object message)
{
logger.info("Message received in the server..");
logger.info("Message is: " + message.toString());
// reply to the client
session.write( /*the reply message here */);
}

关于client - Apache Mina 中的服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5584684/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com