摘要:
//WSAEventSelect.h#include "CInitSocket.h"typedef struct _SOCKET_OBJ{ SOCKET sock; //套接字句柄 HANDLE hEvent; //与次套接字相关的事件对象句柄 sockaddr_in addrRemote; //客户端地址信息 _SOCKET_OBJ *pNext; //指向下一个SOCKET_OBJ对象,构成链表}SOCKET_OBJ,*PSOCKET_OBJ;typedef struct _THREAD_OBJ{ HANDLE hEvents[WSA_MAXIMUM_WAIT... 阅读全文
摘要:
#include "CInitSocket.h"#include <iostream>using namespace std;CInitSock initsocket;int main(){//时间句柄和套接字句柄数组WSAEVENT eventArrary[WSA_MAXIMUM_WAIT_EVENTS];SOCKET sockArray[WSA_MAXIMUM_WAIT_EVENTS];int nEventTotal=0; //事件总数USHORT nPort=4567;SOCKET ListenSocket=socket(AF_INET,SOCK_STRE 阅读全文
摘要:
#include <WINSOCK2.H>#pragma comment(lib,"ws2_32")class CInitSock{public: CInitSock(BYTE minorVer=2,BYTE majorVer=2) { WSADATA wsaData; WORD sockVersion=MAKEWORD(minorVer,majorVer); if (WSAStartup(sockVersion,&wsaData)!=0) { exit(0); } if ( LOBYTE( wsaData.wVersion ) != minorVer 阅读全文
摘要:
#include <WINSOCK2.H>#include <iostream>#pragma comment(lib,"ws2_32")int main(){using namespace std;WSADATA wsaData;WORD sockVersion=MAKEWORD(2,2);if (WSAStartup(sockVersion,&wsaData)!=0){ cout<<"套接字库加载失败!"; exit(0);}if ( LOBYTE( wsaData.wVersion ) != 2 || H 阅读全文