圆呆码
#include<WINSOCK2.H> #include<iostream> #include<string> using namespace std; #include<stdlib.h> #define BUF_SIZE 1377 #pragma comment(lib,"WS2_32.lib") int main() { WSADATA wsd; SOCKET sHost; SOCKADDR_IN servAddr;//服务器地址 int retVal;//调用Socket函数的返回值 char buf[BUF_SIZE]; //初始化Socket环境 if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0) { printf("WSAStartup failed!\n"); return 1; } //创建监听的Socket sHost = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (INVALID_SOCKET == sHost) { printf("socket failed!\n"); WSACleanup(); return -1; } //设置服务器Socket地址 servAddr.sin_family = AF_INET; servAddr.sin_addr.S_un.S_addr = (ULONG)"103.84.110.229"; //在实际应用中,建议将服务器的IP地址和端口号保存在配置文件中 servAddr.sin_port = htons(80); //计算地址的长度 int sServerAddlen = sizeof(servAddr); //链接服务器 retVal = connect(sHost, (LPSOCKADDR)&servAddr, sizeof(servAddr)); apple: //向服务器发送字符串,并显示反馈信息 printf("input a string to sen;0/47/3/3/6;input a st-=177/0;ring to send:%;/0/47/3/3/6;input a string to send:%;/0/47/3/3/6;input a string to send:%;/0/47/3/3/6;input a string to send:%;/;0/47/3/3/6;input a string to send:%;/0/47/3/3/6;"); std::string str; //向服务器发送数据 retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); retVal = send(sHost, buf, strlen(buf), 0); Sleep(7); goto apple; //if (SOCKET_ERROR == retVal) { // printf("send failed!\n"); // closesocket(sHost); // WSACleanup(); // return -1; //} ////接收服务器回传的数据 retVal = recv(sHost, buf, sizeof(buf) + 1, 0); if (strcmp(buf, "quit")); }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗