16#define WIN32_LEAN_AND_MEAN
22#pragma comment(lib, "wsock32")
30#ifndef FILE_FLAG_FIRST_PIPE_INSTANCE
31#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000
57static void dbg_trace(
char mode,
const char*
buffer,
int l)
59 static char s_mode =
'\0';
74 if (*
p==
'\n' || !*
p ) {
119 int rem_len =
sizeof(rem_addr);
237 const char* pipe_name;
280 puts(
"\nnamed pipe connected, now waiting for TCP connection...");
286 puts(
"TCP connection established.");
305 puts(
"\nconnection closed.");
RTL_CRITICAL_SECTION CritSect
int puts(const char *string)
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
#define GetCurrentProcess()
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
BOOL WINAPI SetPriorityClass(IN HANDLE hProcess, IN DWORD dwPriorityClass)
BOOL WINAPI SetThreadPriority(IN HANDLE hThread, IN int nPriority)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
GLdouble GLdouble GLdouble r
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define FILE_FLAG_OVERLAPPED
#define sprintf(buf, format,...)
#define FILE_FLAG_FIRST_PIPE_INSTANCE
static void print_error(DWORD win32_error)
static SOCKET s_srv_socket
SOCKET open_tcp_connect()
LONG read_pipe(HANDLE hPipe, SOCKET sock)
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
WriterThread(SOCKET sock, HANDLE hPipe)
static DWORD WINAPI WriterThreadRoutine(LPVOID param)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
DWORD WINAPI GetLastError(void)
HANDLE WINAPI GetCurrentThread(void)
#define PIPE_ACCESS_DUPLEX
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI InitializeCriticalSection(LPCRITICAL_SECTION)
#define HIGH_PRIORITY_CLASS
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define THREAD_PRIORITY_HIGHEST
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define ERROR_BROKEN_PIPE
#define ERROR_PIPE_LISTENING