Presentation is loading. Please wait.

Presentation is loading. Please wait.

Echo Server/Client Speaker:Fang.

Similar presentations


Presentation on theme: "Echo Server/Client Speaker:Fang."— Presentation transcript:

1 Echo Server/Client Speaker:Fang

2 Outline 1.Echo Server/Client 2. TCP Sockets 3.Java Echo Server
4.Java Echo Client in Android 5.Demo

3 1.Echo Server/Client 目的 以Socket連接,互相溝通 Client送出字串給 Server

4 2.TCP Sockets Endpoint for communication
Consists of the pair <IP address, Port> Port is between 1024 and 65535 TCP connection consists of a pair of sockets Server Listens on a port Client Requests for connection

5 2.TCP Sockets For example Client Server
IP: Port: 12345 Server IP: Port: 80 Connection is uniquely identified by the socket pair < : 12345, : 80>

6 3.Java Echo Server Flow Note: NoThread
聽一個特定的port,並等待client提出connection request 接受request,建立socket連線 藉由socket讀取來自client的string 藉由socket傳送一樣的string給client 關閉與此client的socket連線 回到第一步驟,繼續等待 Note: NoThread 一次只能服務一個client

7 3.Java Echo Server Port 執行echo的動作

8 3.Java Echo Server 處理input 處理output

9 3.Java Echo Server

10 4.Echo Client in Android Flow Note:
指定Server IP與Port給socket,使用socket與server端之socket建立連線 透過socket傳送string給server 透過socket接收server傳回之echo string 關閉與server之連線 Note: 需在AndroidManifest.xml中開放User Permission android.permission.INTERNET

11 4.Echo Client in Android 處理input 處理output 與server建立連線
將fromuser字串寫入socket中 從socket中讀出string

12 5.Demo

13 Thanks!


Download ppt "Echo Server/Client Speaker:Fang."

Similar presentations


Ads by Google