| 14 | */ |
| 15 | |
| 16 | int main(void) { |
| 17 | int sfd, bytes, ret; |
| 18 | char request[128], buf[32]; |
| 19 | |
| 20 | buf[31] = 0; |
| 21 | |
| 22 | ret = sfd = create_inet_stream_socket("borgac.net", "80", |
| 23 | LIBSOCKET_IPv4, 0); |
| 24 | |
| 25 | if (ret < 0) { |
| 26 | perror(0); |
| 27 | exit(1); |
| 28 | } |
| 29 | |
| 30 | sprintf(request, "GET / HTTP/1.1\nHost: borgac.net\n\n"); |
| 31 | |
| 32 | ret = write(sfd, request, strlen(request)); |
| 33 | |
| 34 | if (ret < 0) { |
| 35 | perror(0); |
| 36 | exit(1); |
| 37 | } |
| 38 | |
| 39 | ret = shutdown_inet_stream_socket(sfd, LIBSOCKET_WRITE); |
| 40 | |
| 41 | if (ret < 0) { |
| 42 | perror(0); |
| 43 | exit(1); |
| 44 | } |
| 45 | |
| 46 | while (0 < (bytes = read(sfd, buf, 31))) write(1, buf, bytes); |
| 47 | |
| 48 | ret = destroy_inet_socket(sfd); |
| 49 | |
| 50 | if (ret < 0) { |
| 51 | perror(0); |
| 52 | exit(1); |
| 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |
nothing calls this directly
no test coverage detected