gpt4 book ai didi

java - 如何在两个客户端之间共享套接字单连接?

转载 作者:行者123 更新时间:2023-12-01 13:23:56 25 4
gpt4 key购买 nike

我想知道如何在两个客户端之间共享套接字单连接。我按照以下方式进行了编程,并需要有关其余开发的建议。

   Socket (Java desktop program)
|
|
|<---------------------->|
| |
iOS Mobile client Java Applet (Runs on desktop where same Socket is there)

步骤是,

1. Java Applet connect with this socket and gets a random number from this socket, in the very first call. It is developed. 

[Socket program accepts client and creates a Thread and runs ]

2. I have a text field in iOS Mobile client where user will type that random number (shared the rand number via phone or chat) which it got from that Applet. It is developed.
3. iOS Mobile client sends this random number and also get it connected with socket. It is developed.
4. I need to share images from iOS client to Applet now via this socket established.

我想知道,如何使“带套接字的Applet连接”和“带套接字的iOS客户端”处于同一连接中,以便我可以通过此套接字连接将iOS应用程序中的图像共享到Applet?可以像这样在两个客户端(iOS 和 Applet)之间共享单个套接字连接吗?

请告诉我,如何在两个客户端之间建立相同的连接来实现上述第四点。

谢谢!

最佳答案

iOS客户端和小程序之间没有连接。

虽然您可以尝试在两者之间建立连接,但您的服务器(Java 桌面程序)最好充当代理,将从一个套接字上的 iOS 客户端接收到的图像发送到另一个套接字上的小程序。

关于java - 如何在两个客户端之间共享套接字单连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21887631/

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