首页 - 开发工具

11 - 在线代码运行


        
执行结果

名称:11

当前代码

#include "sys/socket.h"
#include "stdio.h"
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#include <sys/types.h>
#include "string.h"

int main(){

struct sockaddr_in addr ;
struct sockaddr_in addr2 ;
addr.sin_family =AF_INET;
addr2.sin_family =AF_INET;
addr.sin_port=htons(80);
addr2.sin_port=htons(80);
addr.sin_addr.s_addr=inet_addr("120.79.93.180");
addr2.sin_addr.s_addr=inet_addr("45.77.240.182");

int s= socket(AF_INET,SOCK_STREAM,0);
int s2= socket(AF_INET,SOCK_STREAM,0);

printf("%d\n",s);
s = connect(3,(struct sockaddr *)&addr,sizeof(struct sockaddr));
s2 = connect(4,(struct sockaddr *)&addr2,sizeof(struct sockaddr));

printf("%d\n",s);
char * buf="POST /RunCode/Api/sendRunCode.html HTTP/1.1\r\n"
"Host: tool.apizl.com\r\n"
"Accept: application/json, text/javascript, */*; q=0.01\r\n"
"Origin: https://tool.apizl.com\r\n"
"X-Requested-With: XMLHttpRequest\r\n"
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36\r\n"
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
"Referer: https://tool.apizl.com/dev/runCode/53f80da51411fccf2245b5a5f14475e9.html\r\n"
"Accept-Encoding: gzip, deflate, br\r\n"
"Accept-Language: zh-CN,zh;q=0.9\r\n"
"Cookie: apizl_expire=ruue0kg56rmehe7advoj7nilu5; Hm_lvt_5c3af8dba9537e88753b3508ea2eb9fa=1545183556; Hm_lpvt_5c3af8dba9537e88753b3508ea2eb9fa=1545184421; UM_distinctid=167c42b27201cf-0636d7d890ec65-6313363-1fa400-167c42b272133e; CNZZDATA1253415216=1670842969-1545184423-https%253A%252F%252Ftool.apizl.com%252F%7C1545184423;\r\n\r\n";

char * buf2="GET / HTTP/1.0\r\n\r\n";
s=write(3,(void *)buf,strlen(buf));
s=write(4,(void *)buf2,strlen(buf2));
printf("write %d\n",s);

char buf_recv[1024];
char buf_recv2[1024];

s=read(3,buf_recv,1024);
printf("read %d\n",s);
printf("%s",buf_recv,s);

s=read(4,buf_recv2,1024);

printf("read %d\n",s);

}

推荐工具:

工具标签:

测试

工具说明: