2014-02-19 56 views
0

我想知道如何共享兩個客戶端之間的套接字單連接。我按照以下方式進行了編程,並需要爲其餘的開發提供建議。如何共享兩個客戶端之間的套接字單連接?

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. 

我想知道,如何讓「的iOS客戶端套接字」是在同一個連接的「帶插座的Applet連接」,並讓我可以通過此套接字連接將圖像從iOS應用程序共享到Applet?單個套接字連接可以像這樣在兩個客戶端(iOS和Applet)之間共享嗎?

請指教一下,我如何實現上面提到的第四點與兩個客戶端之間建立的相同連接。

謝謝!

回答

1

iOS客戶端和小程序之間沒有連接。

儘管您可以嘗試在兩者之間建立連接,但您的服務器(Java桌面程序)可能更好地充當將從一個套接字上的iOS客戶端接收的圖像發送到另一個套接字上的小應用程序。

+0

好的。那麼您是說,我會將iOS和Applet分別連接到Socket? – Stella

+0

是的,它們都分別連接到服務器並通過它使用隨機數共享數據以確定要連接哪些套接字。 –

+0

好吧,明白了!請求套接字時,您是否希望我發送隨機數?如果我有多個獨立的移動客戶端,它會工作嗎? – Stella

相關問題