資源簡介
我用MFC VC6編寫的一個 TCP 一對多通信的程序,就是服務器端利用多線程技術(不使用Select等任何模型), 能同時接收多個客戶端的消息,
其次, 服務器端還能將消息群發給所有已連接的客戶端, 實現的基本思路 是將每個線程中 accept函數返回的套接字 都保存到一個套接字數組中,套接字地址也保存到一個數組中。然后在“群發”的 按鈕消息中,用for循環 遍歷套接字數組,循環執行 send函數將消息發送給套接字數組中所有的套接字。
該程序簡單完整,非常適合初學者研究WinSock一對多通信

代碼片段和文件信息
//?stdafx.cpp?:?source?file?that?includes?just?the?standard?includes
// TCPzcli.pch?will?be?the?pre-compiled?header
// stdafx.obj?will?contain?the?pre-compiled?type?information
#include?“stdafx.h“
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????35100??2019-01-28?21:19??Chat服務器端\Chat.aps
?????文件????????961??2019-01-31?16:22??Chat服務器端\Chat.clw
?????文件???????2129??2019-01-18?10:39??Chat服務器端\Chat.cpp
?????文件???????4123??2019-01-18?10:39??Chat服務器端\Chat.dsp
?????文件????????514??2019-01-18?10:39??Chat服務器端\Chat.dsw
?????文件???????1302??2019-01-18?10:39??Chat服務器端\Chat.h
?????文件??????58368??2019-01-31?16:22??Chat服務器端\Chat.ncb
?????文件??????54784??2019-01-31?16:22??Chat服務器端\Chat.opt
?????文件????????907??2019-01-31?11:56??Chat服務器端\Chat.plg
?????文件???????5074??2019-01-28?21:19??Chat服務器端\Chat.rc
?????文件???????6700??2019-01-31?11:55??Chat服務器端\ChatDlg.cpp
?????文件???????1793??2019-01-28?21:18??Chat服務器端\ChatDlg.h
?????文件???????5534??2019-01-28?10:31??Chat服務器端\chatdlg2.cpp
?????文件???????3543??2019-01-18?10:39??Chat服務器端\ReadMe.txt
?????文件???????1078??2019-01-18?10:39??Chat服務器端\res\Chat.ico
?????文件????????396??2019-01-18?10:39??Chat服務器端\res\Chat.rc2
?????文件????????819??2019-01-28?21:19??Chat服務器端\resource.h
?????文件????????206??2019-01-18?10:39??Chat服務器端\StdAfx.cpp
?????文件???????1102??2019-01-18?10:39??Chat服務器端\StdAfx.h
?????文件???????3597??2018-06-24?15:12??Chat客戶端\ReadMe.txt
?????文件???????1078??2018-06-24?15:12??Chat客戶端\res\TCPzcli.ico
?????文件????????399??2018-06-24?15:12??Chat客戶端\res\TCPzcli.rc2
?????文件????????915??2018-06-24?15:23??Chat客戶端\resource.h
?????文件????????209??2018-06-24?15:12??Chat客戶端\StdAfx.cpp
?????文件???????1054??2018-06-24?15:12??Chat客戶端\StdAfx.h
?????文件??????20936??2019-01-31?16:23??Chat客戶端\TCPzcli.aps
?????文件???????1345??2019-01-31?16:23??Chat客戶端\TCPzcli.clw
?????文件???????2077??2018-06-24?15:12??Chat客戶端\TCPzcli.cpp
?????文件???????4177??2018-06-24?15:12??Chat客戶端\TCPzcli.dsp
?????文件????????520??2018-06-24?15:12??Chat客戶端\TCPzcli.dsw
............此處省略14個文件信息
- 上一篇:掌紋識別c/c++代碼
- 下一篇:UE4C++游戲視頻教程
評論
共有 條評論