Java 中无法访问 UDP 客户端
我正在运行一个简单的 UDP Java 服务器,它在连接时收集客户端的 IP 和端口,并将信息存储在数据库中。
客户端仍在监听服务器。 服务器停止。
之后,服务器想要重用数据库信息,到达客户端; 由于客户端仍在侦听服务器的同一端口,我想客户端应该接收通信。
我是UDP新手,请让我知道实现上述目标的方法。 谢谢。
让我重新表述一下这个问题,因为我确实尝试了 Stackoverflow 成员建议的方法。
服务器在很短的时间内可以联系到客户端,但是10分钟后客户端就无法访问了; 尽管客户端似乎已准备好一直监听服务器,但即使多次尝试,服务器也无法到达客户端。 这可能是什么原因造成的? 请让我知道处理这个问题的方法
I am running a simple UDP Java Server, which collects IP and Port of Client when connected, store information in Database.
Client is still listening to server. Server stops.
Later, server want to reuse the database information, to reach the client; and as the client is still listening to same port of server, I guess client should receive the communication.
I am new to UDP, please let me know the way to achieve the above objective. Thank you.
Let me rephrase the question as I did try the ways suggested by members of Stackoverflow.
The client can be contacted by server within a short timespan, but after say 10 mins the client is unreachable; although it appears client is ready to listen to server for all the time but the server cannot reach client even if tried for several time. What could be cause for this? please let me know the way to deal with this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您对 UDP 协议(RFC 768)有点困惑。 我认为回顾 UDP 协议以了解 UDP 和 TCP 之间的差异会很有帮助。
关于您的具体问题,如果没有任何类型的代码,很难知道您的确切问题是什么。 有一个 UDP 中的客户端-服务器示例 可用在阳光下的教程。
I think you are a bit confused regarding the UDP protocol (RFC 768). I think it would be helpful to review the UDP protocol to understand the differences between UDP and TCP.
Regarding your specific problem, it is difficult to know what is your exact problem without any type of code. There is a Client-Server in UDP example available in the sun tutorials.
UDP 是无会话的,所以我想它确实应该有效。
事情会是这样的:
UDP is sessionless, so I guess it should indeed work.
It would go something like that: