| 12 | */ |
| 13 | |
| 14 | int main(void) { |
| 15 | int sfd, bytes = 1, ret; |
| 16 | const char* string = "abcdefghijklmnopqrstuvwxyz"; |
| 17 | char buf[16]; |
| 18 | |
| 19 | memset(buf, 0, sizeof(buf)); |
| 20 | |
| 21 | ret = sfd = create_unix_stream_socket("/tmp/echosock", 0); |
| 22 | |
| 23 | if (ret < 0) { |
| 24 | perror(0); |
| 25 | exit(1); |
| 26 | } |
| 27 | |
| 28 | ret = write(sfd, string, 26); |
| 29 | |
| 30 | if (ret < 0) { |
| 31 | perror(0); |
| 32 | exit(1); |
| 33 | } |
| 34 | |
| 35 | ret = shutdown_unix_stream_socket(sfd, LIBSOCKET_WRITE); // Send EOF |
| 36 | |
| 37 | if (ret < 0) { |
| 38 | perror(0); |
| 39 | exit(1); |
| 40 | } |
| 41 | |
| 42 | while (bytes > 0) { |
| 43 | ret = bytes = read(sfd, buf, 15); |
| 44 | |
| 45 | if (ret < 0) { |
| 46 | perror(0); |
| 47 | exit(1); |
| 48 | } |
| 49 | |
| 50 | write(1, buf, bytes); |
| 51 | } |
| 52 | |
| 53 | ret = destroy_unix_socket(sfd); |
| 54 | |
| 55 | if (ret < 0) { |
| 56 | perror(0); |
| 57 | exit(1); |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | } |
nothing calls this directly
no test coverage detected