0

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!

Stella
  • 1,657
  • 3
  • 34
  • 83

1 Answers1

1

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.

Nick Holt
  • 31,429
  • 4
  • 46
  • 56
  • OK..So you are saying, I'll make a connection from iOS and Applet separately to Socket? – Stella Feb 19 '14 at 17:36
  • Yes, both connect to the server separately and share data via it using the random number to work out which sockets to connect. – Nick Holt Feb 19 '14 at 17:43
  • OK, got it! Do you want me to send random number when requesting the socket? Will it work if i have multiple separate mobile clients? – Stella Feb 19 '14 at 17:46
  • You'd connect the socket, send the number and then it's down to how the server interprets that number - if you need to support multiple iOS client with a single applet, then you'll have to code that way. – Nick Holt Feb 19 '14 at 17:52
  • OK..It won't be multiple iOS clients with single applet, it will be multiple iOS clients with multiple sockets. So, each iOS client will be shared data with separate Applet. – Stella Feb 19 '14 at 17:54