freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

網(wǎng)絡(luò)聊天工具socket編程心得doc(已修改)

2025-07-30 14:22 本頁(yè)面
 

【正文】 網(wǎng)絡(luò)聊天工具Socket編程心得首先要了解TCP協(xié)議通信的流程:1。服務(wù)器端首先創(chuàng)建服務(wù)器套接字2。服務(wù)器套接字監(jiān)聽(tīng)一個(gè)端口,等待客戶端的請(qǐng)求3??蛻舳藙?chuàng)建一個(gè)客戶端套接字4??蛻舳讼蚍?wù)器發(fā)送請(qǐng)求5。服務(wù)器確認(rèn)與客戶端的連接6??蛻舳撕头?wù)器利用建立的連接進(jìn)行通信7。通信完畢后,客戶端和服務(wù)器關(guān)閉各自的連接Socket編程基礎(chǔ):一。利用Socket建立服務(wù)器程序1。創(chuàng)建一個(gè)服務(wù)器套接字,用IP地址和端口初始化服務(wù)器IPAddress ipAddress = ()。TcpListener listener = new TcpListener(ipAddress, 1234)。2。監(jiān)聽(tīng)服務(wù)器端口()。3。確認(rèn)與客戶端的連接 Socket socket = ()。4。取得客戶端傳送過(guò)來(lái)的信息 //將傳送過(guò)來(lái)的信息存入字節(jié)數(shù)組中byte[] buffer = new byte[1024]。(buffer)。5。處理客戶端的請(qǐng)求并回應(yīng)客戶端 string message = hello。byte[] outbytes = (())。(outbytes, , 0)。6。斷開(kāi)客戶端的連接,釋放客戶端連接 ()。7。關(guān)閉服務(wù)器,釋放服務(wù)器連接 ()。二。利用Socket建立客戶端程序1。創(chuàng)建客戶端套接字 TcpClient tcpClient = new TcpClient()。2。連接服務(wù)器 ((), 1234)。3。得到與服務(wù)器通信的流通道 NetworkStream stream = ()。4。向服務(wù)器發(fā)送數(shù)據(jù) string cmd = 。byte[] outbytes = (())。(outbytes, 0, )。5。接收從服務(wù)器發(fā)回的數(shù)據(jù) byte[] buffer = new byte[1024]。int len = (buffer, 0, )。string msg = (buffer, 0, len)。6。斷開(kāi)連接 ()。:using System。using 。using 。using 。using 。using 。using 。using 。using 。namespace ChatServer{ /// summary /// Form1 的摘要說(shuō)明。 /// /summary public class ChatServerForm : { /// summary /// 必需的設(shè)計(jì)器變量。 /// /summary private ponents = null。 // The port static int port = 1234。 private TcpListener listener。 private Socket tmpSocket。 // The maximal clients the server can hold static int MaxNum = 100。 private label1。 private label2。 private txtHost。 private txtPort。 private btnStart。 private btnExit。 private label3。 private cmbCurUserList。 private lstInfo。 // The array clients is to save the online clients static ArrayList clients = new ArrayList()。 public ChatServerForm() { // // Windows 窗體設(shè)計(jì)器支持所必需的 // InitializeComponent()。 // // TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼 // } /// summary /// 清理所有正在使用的資源。 /// /summary protected override void Dispose( bool disposing ) { if( disposing ) { if (ponents != null) { ()。 } } ( disposing )。 } region Windows 窗體設(shè)計(jì)器生成的代碼 /// summary /// 設(shè)計(jì)器支持所需的方法 不要使用代碼編輯器修改 /// 此方法的內(nèi)容。 /// /summary private void InitializeComponent() { = new ()。 = new ()。 = new ()。 = new ()。 = new ()。 = new ()。 = new ()。 = new ()。 = new ()。 ()。 // // label1 // = true。 = new (32, 32)。 = label1。 = new (54, 17)。 = 0。 = 主機(jī)號(hào):。 // // label2 // = true。 = new (32, 72)。 = label2。 = new (54, 17)。 = 1。 = 端口號(hào):。 // // txtHost // = new (96, 24)。 = txtHost。 = new (128, 21)。 = 2。 = 。 // // txtPort // = new (96, 64)。 = txtPort。 = new (128, 21)。 = 3。 = 。 // // btnStart // = new (256, 24)。 = btnStart。 = 4。 = 啟動(dòng)。 += new ()。 // // btnExit // = new (256, 64)。 = btnExit。 = 5。 = 退出。 += new ()。 // // label3 // = true。 = new (24, 112)。 = label3。 = new (91, 17)。 = 6。 = 當(dāng)前在線用戶:。 // // cmbCurUserList // = new (120, 112)。 = cmbCurUserList。 = new (136, 20)。 = 7。 // // lstInfo // = 12。 = new (0, 144)。 = lstInfo。 = new (344, 160)。 = 8。 // // ChatServerForm // = new (6, 14)。 = new (344, 301)。 ()。 ()。 ()。 ()。 ()。 ()。 ()。 ()。 ()。
點(diǎn)擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號(hào)-1