-
大小: 883KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-02
- 語(yǔ)言: 其他
- 標(biāo)簽: 網(wǎng)絡(luò)??IO模型??代碼??
資源簡(jiǎn)介
參考了《window網(wǎng)絡(luò)編程》一書,抽空整理寫了常用的網(wǎng)絡(luò)IO模式的例子,難免有不足之處敬請(qǐng)指出,歡迎討論,大家共同進(jìn)步! :-D
郵箱:wjj1234@sina.com
1.每個(gè)例子都包含一個(gè)Server工程,一個(gè)Client工程,
客戶端的代碼都是相同的。例子很簡(jiǎn)單,就是Server和Client之間應(yīng)答式的發(fā)送一個(gè)20個(gè)字節(jié)長(zhǎng)的
數(shù)字和字母組成的隨機(jī)序列。
2.每個(gè)工程都包含有一個(gè)Globle.h的頭文件,主要用于產(chǎn)生字母和數(shù)字的隨機(jī)序列,其實(shí)也就是封裝了
一下STL的隨機(jī)序列的算法。為了省事,Globle.h文件里面也包含了定義,主要是本身的內(nèi)容就不多,
也就沒有把定義放到單獨(dú)
代碼片段和文件信息
/*
client.cpp??
*/
#include?
#include?
#include?
#include?
#include?“Globle.h“
#pragma?comment(lib?“ws2_32.lib“)
#define MAX_THREAD 5
HANDLE?ThreadPool[MAX_THREAD]?=?{NULL};
volatile?BOOL?bExit?=?FALSE;
void?Init()
{
InitializeCriticalSection(&csGeneralData);
InitializeCriticalSection(&csShowMsg);
srand(time(0));
}
void?BeforeExit()
{
DeleteCriticalSection(&csGeneralData);
DeleteCriticalSection(&csShowMsg);
}
DWORD?GetSocket(SOCKET?&s)
{
DWORD?dwCode;
char?Msg[1024]?=?““;
closesocket(s);
s?=?socket(AF_INET?SOCK_STREAM?IPPROTO_TCP);?//建立一個(gè)TCP/IP協(xié)議的套接字
if(s?==?INVALID_SOCKET)
{
dwCode?=?WSAGetLastError();
sprintf(Msg?“\nCan‘t?create?the?socket:%d?\n“?dwCode);
ShowMsg(Msg);
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????148??2008-12-03?14:16??5大網(wǎng)絡(luò)IO模型代碼示例\Del.bat
?????文件???????4238??2008-12-03?15:08??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.cpp
?????文件???????3401??2008-12-02?15:45??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.dsp
?????文件????????537??2008-12-02?15:45??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.dsw
?????文件??????58368??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.ncb
?????文件?????211968??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.opt
?????文件???????1126??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Client.plg
?????目錄??????????0??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Debug
?????文件????????962??2008-12-03?15:06??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Globle.h
?????文件???????8337??2008-12-03?16:49??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.cpp
?????文件???????3405??2008-12-02?16:26??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.dsp
?????文件????????537??2008-12-02?15:47??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.dsw
?????文件??????58368??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.ncb
?????文件?????211968??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.opt
?????文件???????1280??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型\Server.plg
?????目錄??????????0??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\select模型
?????文件???????4238??2008-12-03?15:08??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.cpp
?????文件???????3401??2008-12-01?23:23??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.dsp
?????文件????????537??2008-12-01?23:40??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.dsw
?????文件??????58368??2008-12-03?16:43??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.ncb
?????文件?????211968??2008-12-03?16:43??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.opt
?????文件???????1150??2008-12-03?16:34??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Client.plg
?????目錄??????????0??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Debug
?????文件????????962??2008-12-03?15:06??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client\Globle.h
?????目錄??????????0??2008-12-03?14:58??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Client
?????目錄??????????0??2008-12-03?17:01??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Server\Debug
?????文件????????962??2008-12-03?15:06??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Server\Globle.h
?????文件???????3579??2008-12-02?17:49??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Server\ReadMe.txt
?????文件???????1078??2008-12-02?17:49??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Server\res\Server.ico
?????文件????????398??2008-12-02?17:49??5大網(wǎng)絡(luò)IO模型代碼示例\WSAAsyncSelect模型\Server\res\Server.rc2
............此處省略84個(gè)文件信息
- 上一篇:花店小程序源碼
- 下一篇:膳食數(shù)據(jù)庫(kù)
評(píng)論
共有 條評(píng)論