Presentation is loading. Please wait.

Presentation is loading. Please wait.

在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息. 檔案下載  範例程式可在下列網址取得  DEMO 程式可在下列網址取得

Similar presentations


Presentation on theme: "在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息. 檔案下載  範例程式可在下列網址取得  DEMO 程式可在下列網址取得"— Presentation transcript:

1 在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息

2 檔案下載  範例程式可在下列網址取得 http://www.cc.chu.edu.tw/~m09702044/ADHOC/DEMO_Code.zip http://ppt.cc/Oyj!  DEMO 程式可在下列網址取得 http://www.cc.chu.edu.tw/~m09702044/ADHOC/UDP_Demo.exe http://ppt.cc/P57f  投影片可在下列網址取得 http://www.cc.chu.edu.tw/~m09702044/ADHOC/ADHOCUDP.pptx http://ppt.cc/W@54

3 目的  在 Ad-hoc 網路中實現點對點發送訊息與廣播訊息。  使用 UDP 通訊協定與網路服務通訊。  利用 UdpClient 類別, UdpClient 類別的屬性和方 法摘要了建立 Socket 以使用 UDP 要求與接收資 料時,所需的詳細資料。

4 程式介面  使用者輸入 textBox2 textBox3 textBox4 richTextBox3

5 命名空間和定義  using System.Net;  using System.Net.Sockets;

6 程式介面

7 本機 IP 位址  可利用本機的 hostname 來取得 IP address  取得 hostname String LocalHostName = Dns.GetHostName()  取得 IP address IPHostEntry ipInfor = Dns.GetHostEntry(LocalHostName)

8 程式介面

9 開始監聽 (button1)  設定通訊埠。 (port)  新建立 UdpClient 並監聽通訊埠等待接收訊息。 (receivingUdpClient = new ???)  設定 client 的 IPEndPoint ,允許接收來自任何來源 端傳送的訊息。 (RemoteIpEndPoint = new ???)  呼叫 WaitForData() 開始接收資料。

10 定義 UdpClient_State  定義 buffer 的大小和目前的 socket

11 WaitForData () ( 等待接收資料 )  檢查是否已經接收完訊息:  如果已經接收完訊息 在非同步作業完成時呼叫的回呼方法。 ( 呼叫 ReadCallback 來處理接收到的訊息, readAsyCallBack = new ???(???))

12 WaitForData () ( 等待接收資料 )  檢查是否已經接收完訊息:  如果尚未接收完訊息 替 Client 新建立 UdpClient_state 開始使用非同步接收來自 client 的訊息。 (recvsocket.???(???, ???))

13 ReadCallback () ( 處理接收到的訊息 )  建立 UdpClient_state 來處理 client 的回應  結束讀取接收到的訊息。 (bytesRead2 = ???.???.??? (???, ???))  儲存接收到的訊息。 (showtxt)

14 ReadCallback () ( 處理接收到的訊息 )  利用跨執行緒的方法輸出訊息。  UpdateUI()

15 程式介面

16 關閉監聽 (button2)  關閉正在監聽的 socket 。 (receivingUdpClient.???)

17 程式介面

18 發送訊息至指定的電腦 (button3)  設定連線的目的端資訊。 (remoteIEP = new ???)  新建立 Udpclient 。 (udpClientsend = new ???)

19 發送訊息至指定的電腦 (button3)  利用 Encoding.Unicode.GetBytes(string s) ,將輸 入的訊息 (string) 轉換為 byte 。 (SendbyteData = ???) ( 例如: " (" + 使用者 + ") 說: \n" + 訊息內容 )  傳送訊息至目的端。 (udpClientsend.???(???, ???, ???))

20 程式介面

21 發送廣播訊息 (button4)  設定廣播目的地 IPEndPoint 。 (bcastIEP = new ???)  新建立 broadcast 的 UdpClient 。 (udpClientbsend = new ???)

22 發送廣播訊息 (button4)  利用 Encoding.Unicode.GetBytes(string s) ,將輸 入的訊息 (string) 轉換為 byte 。 (bcastSendbyteData = ???) ( 例如: “ [ 廣播 ] (" + 使用者 + ") 說: \n" + 訊息內容 )  傳送訊息至目的端。 (udpClientsend.???(???, ???, ???))

23 示意圖


Download ppt "在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息. 檔案下載  範例程式可在下列網址取得  DEMO 程式可在下列網址取得"

Similar presentations


Ads by Google