| 1 | #include <sys/types.h> |
| 2 | #include <sys/socket.h> |
| 3 | #include <netinet/in.h> |
| 4 | #include <arpa/inet.h> |
| 5 | #include <netdb.h> |
| 6 | #include <stdio.h> |
| 7 | |
| 8 | #include <stdlib.h> |
| 9 | |
| 10 | //#include <sys/types.h> |
| 11 | //#include <sys/socket.h> |
| 12 | //#include <netinet/in.h> |
| 13 | //#include <arpa/inet.h> |
| 14 | #include <sys/wait.h> |
| 15 | #include <sys/stat.h> |
| 16 | //#include <stdlib.h> |
| 17 | //#include <stdio.h> |
| 18 | #include <time.h> |
| 19 | #include <unistd.h> |
| 20 | #include <string.h> |
| 21 | #include <dirent.h> |
| 22 | #include <fcntl.h> |
| 23 | #include <errno.h> |
| 24 | |
| 25 | |
| 26 | int main() { |
| 27 | |
| 28 | |
| 29 | char buf[4096]; |
| 30 | int len; |
| 31 | int fd=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP); |
| 32 | struct sockaddr_in si; |
| 33 | si.sin_family=PF_INET; |
| 34 | inet_aton("127.0.0.1",&si.sin_addr); |
| 35 | si.sin_port=htons(80); |
| 36 | connect(fd,(struct sockaddr*)si,sizeof si); |
| 37 | write(fd,"GET / HTTP/1.0\r\n\r\n"); |
| 38 | len=read(fd,buf,sizeof buf); |
| 39 | close(fd); |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | } |