1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#include "inspircd.h"
#include "threadengine.h"
#include "inspircd_namedpipe.h"
#include <windows.h>
void IPCThread::Run()
{
LPTSTR Pipename = "\\\\.\\pipe\\InspIRCdStatus";
Pipe = CreateNamedPipe ( Pipename,
PIPE_ACCESS_DUPLEX, // read/write access
PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
MAXBUF, // output buffer size
MAXBUF, // input buffer size
1000, // client time-out
NULL); // no security attribute
if (Pipe == INVALID_HANDLE_VALUE)
return;
while (GetExitFlag() == false)
{
// Trying connectnamedpipe in sample for CreateNamedPipe
// Wait for the client to connect; if it succeeds,
// the function returns a nonzero value. If the function returns
// zero, GetLastError returns ERROR_PIPE_CONNECTED.
Connected = ConnectNamedPipe(Pipe, NULL) ? TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
if (Connected)
{
Success = ReadFile (Pipe, // handle to pipe
Request, // buffer to receive data
MAXBUF, // size of buffer
&BytesRead, // number of bytes read
NULL); // not overlapped I/O
Request[BytesRead] = '\0';
//printf("Data Received: %s\n",chRequest);
if (!Success || !BytesRead)
break;
FlushFileBuffers(Pipe);
DisconnectNamedPipe(Pipe);
}
else
{
// The client could not connect.
CloseHandle(Pipe);
}
SleepEx(100, FALSE);
}
CloseHandle(Pipe);
}
IPC::IPC(InspIRCd* Srv) : ServerInstance(Srv)
{
/* The IPC pipe is threaded */
thread = new IPCThread(Srv);
Srv->Threads->Create(thread);
}
void IPC::Check()
{
}
IPC::~IPC()
{
thread->SetExitFlag();
delete thread;
}
|