Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Valid pipe name on Windows #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions code/pipe-echo-server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
}
Expand Down