Java 中的多播
我有很多关于这个例如。因此枚举它们:
- 为什么它们使用数据报套接字?还有其他替代方案吗?
- 我试图通过这个示例中的数据报套接字发送对象< /a>.服务器需要很长时间才能从客户端接收对象。还有其他选择吗?
注意 - 我正在尝试集成这两个程序来制作一个网络发现程序,其中客户端以对象的形式回复其详细信息。
I've got a lot of questions regarding this e.g.. Hence enumerating them:
- Why do they use datagram sockets? Is there another alternative to them?
- I'm trying to send objects over the datagram sockets in this example. It takes a long time for the server to receive the object from the client's side. Is there any alternative to that as well?
Note - I'm trying to integrate both programs to make a network discovery program wherein the client replies with it's details in the form of an object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于第一个问题,您需要数据报(UDP),因为 tcp 是面向连接的协议。即每个连接用于一台服务器和一个客户端之间的通信。您可以将多个客户端连接到服务器,但它们都是单独的单播通信。
关于你的第二个问题,我认为你观察到的延迟不是由于你的代码造成的。发布有关您的拓扑等的更多详细信息以帮助解决该问题。
For your first question, you need datagrams (UDP) because tcp is a connection oriented protocol. i.e., each connection is for communication between one server and one client. You can have multiple clients connected to a server, but they'd all be individual unicast communication.
Regarding your second question, I don't think a delay you observe is due to your code. Post more details about your topology, etc. to help solve that issue.