renqingquan-patch-2
into master
@@ -0,0 +1,44 @@ | |||||
#include <stdio.h> | |||||
#include <unistd.h> | |||||
#include <string.h> | |||||
#include <sys/socket.h> | |||||
#include <arpa/inet.h> | |||||
#define SERV_IP "127.0.0.1" | |||||
#define SERV_PORT 6666 | |||||
int main(void) | |||||
{ | |||||
int sfd, len; | |||||
struct sockaddr_in serv_addr; | |||||
char buf[BUFSIZ]; | |||||
/*创建一个socket 指定IPv4 TCP*/ | |||||
sfd = socket(AF_INET, SOCK_STREAM, 0); | |||||
/*初始化一个地址结构:*/ | |||||
bzero(&serv_addr, sizeof(serv_addr)); //清零 | |||||
serv_addr.sin_family = AF_INET; //IPv4协议族 | |||||
inet_pton(AF_INET, SERV_IP, &serv_addr.sin_addr.s_addr); //指定IP 字符串类型转换为网络字节序 参3:传出参数 | |||||
serv_addr.sin_port = htons(SERV_PORT); //指定端口 本地转网络字节序 | |||||
/*根据地址结构链接指定服务器进程*/ | |||||
connect(sfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)); | |||||
while (1) { | |||||
/*从标准输入获取数据*/ | |||||
fgets(buf, sizeof(buf), stdin); | |||||
/*将数据写给服务器*/ | |||||
write(sfd, buf, strlen(buf)); //写个服务器 | |||||
/*从服务器读回转换后数据*/ | |||||
len = read(sfd, buf, sizeof(buf)); | |||||
/*写至标准输出*/ | |||||
write(STDOUT_FILENO, buf, len); | |||||
} | |||||
/*关闭链接*/ | |||||
close(sfd); | |||||
return 0; | |||||
} | |||||
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》