| 12 | */ |
| 13 | |
| 14 | int main(void) { |
| 15 | int sfd, cfd, bytes, ret; |
| 16 | char buf[16]; |
| 17 | |
| 18 | buf[15] = 0; |
| 19 | |
| 20 | ret = sfd = create_unix_server_socket("/tmp/echosock", LIBSOCKET_STREAM, 0); |
| 21 | |
| 22 | if (ret < 0) { |
| 23 | perror(0); |
| 24 | exit(1); |
| 25 | } |
| 26 | |
| 27 | for (;;) { |
| 28 | ret = cfd = accept_unix_stream_socket(sfd, 0); |
| 29 | |
| 30 | if (ret < 0) { |
| 31 | perror(0); |
| 32 | exit(1); |
| 33 | } |
| 34 | |
| 35 | while (0 < (bytes = read(cfd, buf, 15))) { |
| 36 | write(cfd, buf, bytes); |
| 37 | write(1, buf, bytes); |
| 38 | } |
| 39 | |
| 40 | ret = destroy_unix_socket(cfd); |
| 41 | |
| 42 | if (ret < 0) { |
| 43 | perror(0); |
| 44 | exit(1); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | ret = destroy_unix_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