资源简介

应该是网上最完成的IOCP实例吧。NT6线程池,VS2010。

资源截图

代码片段和文件信息

#pragma warning(disable:4996)
#include “Utility.h“
#include “EasyClient.h“

#include 
#include 
#include 
#include 
#include 

#pragma comment(lib “ws2_32.lib“)

#define MAX_BUF_SIZE 10240


struct THARG{
int id; //从0开始
char ip[40];
char port[20];
char data[MAX_BUF_SIZE];
};


struct Message{
ULONG32 len; //buffer中数据的字节数
char buffer[MAX_BUF_SIZE]; //实际数据
};

void SockInit()
{
WSADATA wsaData;

WSAStartup(MAKEWORD(2 0) &wsaData);
}


void SockFinal()
{
WSACleanup();
}


int SendMessage(SOCKET sock char *data)
{
Message msg;

msg.len = strlen(data) + 1;
strcpy(msg.buffer data);

int ret = send(sock (char*)&msg msg.len + sizeof(ULONG32) 0);
if(ret <= 0)
return ret;

assert(ret == msg.len + sizeof(ULONG32));
return 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-05-31 11:39  CodingNote-master\
     文件         177  2014-05-31 11:39  CodingNote-master\.gitignore
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\Debug\
     文件        2917  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\Debug\EasyClient.Build.CppClean.log
     文件         444  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\Debug\EasyClient.log
     文件        3784  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\EasyClient.cpp
     文件         152  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\EasyClient.h
     文件        4032  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\EasyClient.vcxproj
     文件        1304  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\EasyClient.vcxproj.filters
     文件         381  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\EasyClient.vcxproj.user
     文件        1201  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\Utility.cpp
     文件         118  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\Utility.h
     文件         319  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyClient\main.cpp
     文件        1334  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp.sln
     文件       42496  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp.suo
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\
     目录           0  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\Debug\
     文件        3228  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\Debug\EasyIocp.Build.CppClean.log
     文件         434  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\Debug\EasyIocp.log
     文件        1620  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyClients.cpp
     文件         798  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyClients.h
     文件       15493  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocp.cpp
     文件        2661  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocp.h
     文件        4472  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocp.vcxproj
     文件        2038  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocp.vcxproj.filters
     文件         141  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocp.vcxproj.user
     文件        1186  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocpError.cpp
     文件         320  2014-05-31 11:39  CodingNote-master\IOCP\EasyIocp\EasyIocp\EasyIocpError.h
............此处省略54个文件信息

评论

共有 条评论