diff options
author | Bernardo Ramos <berna.gensis@gmail.com> | 2017-04-29 18:35:54 +0000 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2017-05-30 12:02:45 -0400 |
commit | f737f941c50fb5331657a2b0664f74f37f8a0a74 (patch) | |
tree | 935c8245d483f5ba99586325ec1f3121f0364bca /docs/code/pipe-echo-server/main.c | |
parent | e133923e935acc3a0b6371372c4ec56f797c8cae (diff) | |
download | libuv-f737f941c50fb5331657a2b0664f74f37f8a0a74.tar.gz libuv-f737f941c50fb5331657a2b0664f74f37f8a0a74.zip |
doc: use valid pipe name in pipe-echo-server
PR-URL: https://github.com/libuv/libuv/pull/1330
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'docs/code/pipe-echo-server/main.c')
-rw-r--r-- | docs/code/pipe-echo-server/main.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/docs/code/pipe-echo-server/main.c b/docs/code/pipe-echo-server/main.c index 4ba4246e..4f28fd03 100644 --- a/docs/code/pipe-echo-server/main.c +++ b/docs/code/pipe-echo-server/main.c @@ -3,6 +3,12 @@ #include <string.h> #include <uv.h> +#ifdef _WIN32 +#define PIPENAME "\\\\?\\pipe\\echo.sock" +#else +#define PIPENAME "/tmp/echo.sock" +#endif + uv_loop_t *loop; typedef struct { @@ -63,7 +69,7 @@ void on_new_connection(uv_stream_t *server, int status) { void remove_sock(int sig) { uv_fs_t req; - uv_fs_unlink(loop, &req, "echo.sock", NULL); + uv_fs_unlink(loop, &req, PIPENAME, NULL); exit(0); } @@ -76,7 +82,7 @@ int main() { signal(SIGINT, remove_sock); int r; - if ((r = uv_pipe_bind(&server, "echo.sock"))) { + if ((r = uv_pipe_bind(&server, PIPENAME))) { fprintf(stderr, "Bind error %s\n", uv_err_name(r)); return 1; } |