黑馬程式設計師 Socket網路程式設計聊天室

2021-06-02 16:25:55 字數 2435 閱讀 3614

windows phone 7手機開發、

.net培訓、期待與您交流!

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

using system.net;

using system.net.sockets;

using system.threading;

using system.io;

namespace mychatroomserver

thread thread = null; //執行accept方法的執行緒

thread recthread = null;//執行receive方法的執行緒

socket socketwatch = null; //全域性變數 監聽客戶端的套接字

dictionarydict = new dictionary();

dictionarydicthread = new dictionary();

private void btnlisten_click(object sender, eventargs e)

///

/// 監聽客戶端的方法

///

void socketlisten()

}///

/// 顯示訊息

///

///

public void showmessage(string s)

///

/// 服務端向客戶端傳送訊息的方法

///

///

///

private void btnsend_click(object sender, eventargs e)

catch (socketexception ex)

catch (exception ex)

}///

/// 服務端接收客戶端訊息的方法

///

public void recmsg(object soc)

else if(arrmsgrec[0]==1)}}

}catch(socketexception ex)

catch (exception ex)}}

private void btnsendall_click(object sender, eventargs e)

showmessage("服務端**訊息");}}

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

using system.net;

using system.net.sockets;

using system.threading;

using system.io;

namespace myconnection

socket socketwatch = null;

thread thread = null;

private void btnconn_click(object sender, eventargs e)

catch (socketexception ex)

catch(exception ex)

thread = new thread(recmsg);

thread.isbackground = true;

thread.start();

}///

/// 接收訊息的方法

///

///

///

private void btnsend_click(object sender, eventargs e)

///

/// 開啟檔案

///

///

///

private void btnopenfile_click(object sender, eventargs e)

}///

/// 傳送檔案

///

///

///

private void btnsendfile_click(object sender, eventargs e)}}

windows phone 7手機開發、

.net培訓、期待與您交流!

黑馬程式設計師 網路程式設計

asp.net android ios開發 net培訓 期待與您交流!1.套接字 socket 用於描述 ip位址和埠,是乙個通訊鏈的控制代碼 就是兩個程式通訊用的 類似於 2.有兩種型別 流式socket 是一種面向連線的 socket 針對於面向連線的 tcp服務應用,安全,但效率低 資料報式 ...

黑馬程式設計師 網路程式設計

asp.net android ios開發 net培訓 期待與您交流!1 網路程式設計 1 網路程式設計 通過程式語言實現計算機鍵的資料通訊。2 網路程式設計的三要素 a ip位址。網路中每一台計算機的唯一標識。b 埠 用於標識程序的邏輯位址 c 協議 定義通訊規則 舉例 我要和小青說話。a 找到小...

黑馬程式設計師 網路程式設計

asp.net unity開發 net培訓 期待與您交流!網路傳輸過程 1,找到對方ip 2,資料傳送到指定埠 每個應用程式對應乙個埠 3,定義通訊規則,即協議 tcp ip tcp 1,面向連線,形成傳輸資料的通道 像打 2,連線中進行大量資料量傳輸 3,可靠協議,三次握手,4,必須建立連線,效率...