mirror of https://github.com/FreeRDP/FreeRDP
libwinpr-pipe: initial basic named pipe support
This commit is contained in:
parent
65bc944def
commit
507899ade9
|
@ -204,10 +204,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
|||
status = connect(pNamedPipe->clientfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un));
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
printf("connect: %d\n", status);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return hNamedPipe;
|
||||
}
|
||||
|
|
|
@ -143,6 +143,12 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
|
||||
pipe = (WINPR_NAMED_PIPE*) Object;
|
||||
|
||||
if (pipe->clientfd != -1)
|
||||
close(pipe->clientfd);
|
||||
|
||||
if (pipe->serverfd != -1)
|
||||
close(pipe->serverfd);
|
||||
|
||||
free(Object);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -240,10 +240,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
|
|||
status = accept(pNamedPipe->serverfd, (struct sockaddr*) &s, &length);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
printf("accept: %d\n", status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pNamedPipe->clientfd = status;
|
||||
|
||||
|
@ -256,6 +253,12 @@ BOOL DisconnectNamedPipe(HANDLE hNamedPipe)
|
|||
|
||||
pNamedPipe = (WINPR_NAMED_PIPE*) hNamedPipe;
|
||||
|
||||
if (pNamedPipe->clientfd != -1)
|
||||
{
|
||||
close(pNamedPipe->clientfd);
|
||||
pNamedPipe->clientfd = -1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static void* named_pipe_client_thread(void* arg)
|
|||
lpNumberOfBytesWritten = 0;
|
||||
nNumberOfBytesToWrite = PIPE_BUFFER_SIZE;
|
||||
|
||||
FillMemory(lpWriteBuffer, 0xAB, PIPE_BUFFER_SIZE);
|
||||
FillMemory(lpWriteBuffer, PIPE_BUFFER_SIZE, 0x59);
|
||||
|
||||
fSuccess = WriteFile(hNamedPipe, lpWriteBuffer, nNumberOfBytesToWrite, &lpNumberOfBytesWritten, NULL);
|
||||
|
||||
|
@ -77,6 +77,8 @@ static void* named_pipe_client_thread(void* arg)
|
|||
free(lpReadBuffer);
|
||||
free(lpWriteBuffer);
|
||||
|
||||
CloseHandle(hNamedPipe);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -143,7 +145,7 @@ static void* named_pipe_server_thread(void* arg)
|
|||
lpNumberOfBytesWritten = 0;
|
||||
nNumberOfBytesToWrite = PIPE_BUFFER_SIZE;
|
||||
|
||||
FillMemory(lpWriteBuffer, 0xCD, PIPE_BUFFER_SIZE);
|
||||
FillMemory(lpWriteBuffer, PIPE_BUFFER_SIZE, 0x45);
|
||||
|
||||
fSuccess = WriteFile(hNamedPipe, lpWriteBuffer, nNumberOfBytesToWrite, &lpNumberOfBytesWritten, NULL);
|
||||
|
||||
|
@ -156,6 +158,8 @@ static void* named_pipe_server_thread(void* arg)
|
|||
free(lpReadBuffer);
|
||||
free(lpWriteBuffer);
|
||||
|
||||
CloseHandle(hNamedPipe);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue