28
28
tv->tv_usec = ((int) tb.millitm) * 1000;
33
win_read(int fd, void *buf, unsigned int length)
36
int res = ReadFile((HANDLE) fd, buf, length, &dwBytesRead, NULL);
38
DWORD error = GetLastError();
39
if (error == ERROR_NO_DATA)
47
win_write(int fd, void *buf, unsigned int length)
50
int res = WriteFile((HANDLE) fd, buf, length, &dwBytesWritten, NULL);
52
DWORD error = GetLastError();
53
if (error == ERROR_NO_DATA)
57
return (dwBytesWritten);
61
socketpair(int d, int type, int protocol, int *sv)
67
sprintf(buf, "\\\\.\\pipe\\levent-%d", count++);
68
/* Create a duplex pipe which will behave like a socket pair */
69
fd = CreateNamedPipe(buf, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_NOWAIT,
70
PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, NULL);
71
if (fd == INVALID_HANDLE_VALUE)
75
fd = CreateFile(buf, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
76
if (fd == INVALID_HANDLE_VALUE)
79
SetNamedPipeHandleState(fd, &dwMode, NULL, NULL);
b'\\ No newline at end of file'