client.cpp
#include <windows.h>
#include <iostream>
#pragma comment(lib, "ws2_32")
#define LEN 1024
#define TRUE 1
#define FALSE_F -1
#define OK 1
#define ERROR_R -1
int main()
{
int i=100;
int ret;
char buf1[LEN];
char buf[LEN];
WORD wdVersionRequired;
WSADATA wsaData;
memset(buf, 0, sizeof(buf));
memset(buf1, 0, sizeof(buf1));
wdVersionRequired = MAKEWORD(2, 2); /* 2.2°汾 */
WSAStartup(wdVersionRequired, &wsaData);
while(i--)
{
SOCKET sock;
&

这是一个C++示例,展示了如何使用WinAPI创建一个客户端和服务器,它们通过Socket进行多线程通信。客户端连接到指定IP和端口,并发送'hello world'消息,服务器接收并回应'yes receive!!'。

2万+

被折叠的 条评论
为什么被折叠?



