首页 - 开发工具

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"
"Connection: keep-alive\r\n"
"Content-Length: 5881\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"
"code_type=c&code=%23include+%22sys%2Fsocket.h%22%0A%23include+%22stdio.h%22%0A%23include+%3Csys%2Ftypes.h%3E%0A%23include+%3Carpa%2Finet.h%3E%0A%23include+%3Cnetinet%2Fin.h%3E%0A%23include+%3Cunistd.h%3E%0A%23include+%3Csys%2Ftypes.h%3E%0A%23include+%22string.h%22%0A%0Aint+main()%7B%0A%0Astruct+sockaddr_in+addr+%3B%0Astruct+sockaddr_in+addr2+%3B%0Aaddr.sin_family+%3DAF_INET%3B%0Aaddr2.sin_family+%3DAF_INET%3B%0Aaddr.sin_port%3Dhtons(80)%3B%0Aaddr2.sin_port%3Dhtons(80)%3B%0Aaddr.sin_addr.s_addr%3Dinet_addr(%22120.79.93.180%22)%3B%0Aaddr2.sin_addr.s_addr%3Dinet_addr(%2245.77.240.182%22)%3B%0A%0Aint+s%3D+socket(AF_INET%2CSOCK_STREAM%2C0)%3B%0Aint+s2%3D+socket(AF_INET%2CSOCK_STREAM%2C0)%3B%0A%0Aprintf(%22%25d%5Cn%22%2Cs)%3B%0As+%3D+connect(3%2C(struct+sockaddr+*)%26addr%2Csizeof(struct+sockaddr))%3B%0As+%3D+connect(4%2C(struct+sockaddr+*)%26addr2%2Csizeof(struct+sockaddr))%3B%0A%0Aprintf(%22%25d%5Cn%22%2Cs)%3B%0Achar+*+buf%3D%22POST+%2FRunCode%2FApi%2FsendRunCode.html+HTTP%2F1.1%5Cr%5Cn%22%0A%22Host%3A+tool.apizl.com%5Cr%5Cn%22%0A%22Connection%3A+keep-alive%5Cr%5Cn%22%0A%22Content-Length%3A+924%5Cr%5Cn%22%0A%22Accept%3A+application%2Fjson%2C+text%2Fjavascript%2C+*%2F*%3B+q%3D0.01%5Cr%5Cn%22%0A%22Origin%3A+https%3A%2F%2Ftool.apizl.com%5Cr%5Cn%22%0A%22X-Requested-With%3A+XMLHttpRequest%5Cr%5Cn%22%0A%22User-Agent%3A+Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML%2C+like+Gecko)+Chrome%2F70.0.3538.110+Safari%2F537.36%5Cr%5Cn%22%0A%22Content-Type%3A+application%2Fx-www-form-urlencoded%3B+charset%3DUTF-8%5Cr%5Cn%22%0A%22Referer%3A+https%3A%2F%2Ftool.apizl.com%2Fdev%2FrunCode%2F53f80da51411fccf2245b5a5f14475e9.html%5Cr%5Cn%22%0A%22Accept-Encoding%3A+gzip%2C+deflate%2C+br%5Cr%5Cn%22%0A%22Accept-Language%3A+zh-CN%2Czh%3Bq%3D0.9%5Cr%5Cn%22%0A%22Cookie%3A+apizl_expire%3Druue0kg56rmehe7advoj7nilu5%3B+Hm_lvt_5c3af8dba9537e88753b3508ea2eb9fa%3D1545183556%3B+Hm_lpvt_5c3af8dba9537e88753b3508ea2eb9fa%3D1545184421%3B+UM_distinctid%3D167c42b27201cf-0636d7d890ec65-6313363-1fa400-167c42b272133e%3B+CNZZDATA1253415216%3D1670842969-1545184423-https%25253A%25252F%25252Ftool.apizl.com%25252F%257C1545184423%3B%5Cr%5Cn%5Cr%5Cn%22%3B%0A%0Achar+*+buf2%3D%22GET+%2F+HTTP%2F1.0%5Cr%5Cn%5Cr%5Cn%22%3B%0As%3Dwrite(3%2C(void+*)buf%2Cstrlen(buf))%3B%0As%3Dwrite(4%2C(void+*)buf2%2Cstrlen(buf2))%3B%0Aprintf(%22write+%25d%5Cn%22%2Cs)%3B%0A%0Achar+buf_recv%5B1024%5D%3B%0Achar+buf_recv2%5B1024%5D%3B%0A%0As%3Dread(3%2Cbuf_recv%2C1024)%3B%0As%3Dread(4%2Cbuf_recv2%2C1024)%3B%0A%0Aprintf(%22read+%25d%5Cn%22%2Cs)%3B%0A%0A%7D&name=\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);

}

推荐工具:

工具标签:

测试

工具说明: