简体   繁体   中英

How to share a socket single connection between two clients?

I want to know how to share a socket single connection between two clients. I have programmed in the following way, and need advise for the rest of the development.

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

Steps are,

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.

I want to know, how to make the 'Applet connection with socket' and 'iOS client with socket' to be in the same connection, so that I can share images from iOS app to Applet via this socket connection? Can a single socket connection be shared between two clients (iOS and Applet) like this?

Please advise me, how can i achieve the 4th point mentioned above with the same connection established between two clients.

Thank you!

There is no connection between the iOS client and the applet.

While you could try to establish a connection between the two, it's probably better for your server (the Java desktop program) to act as a proxy sending images received from the iOS client on one socket to the applet on the other socket.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM