MCPcopy Create free account
hub / github.com/audacity/audacity / PipeServer

Function PipeServer

modules/scripting/mod-script-pipe/PipeServer.cpp:13–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11extern "C" int DoSrvMore( char * pOut, size_t nMax );
12
13void PipeServer()
14{
15 HANDLE hPipeToSrv;
16 HANDLE hPipeFromSrv;
17
18 static const TCHAR pipeNameToSrv[] = _T("\\\\.\\pipe\\ToSrvPipe");
19
20 hPipeToSrv = CreateNamedPipe(
21 pipeNameToSrv ,
22 PIPE_ACCESS_DUPLEX,
23 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
24 PIPE_UNLIMITED_INSTANCES,
25 nBuff,
26 nBuff,
27 50,//Timeout - always send straight away.
28 NULL);
29 if( hPipeToSrv == INVALID_HANDLE_VALUE)
30 return;
31
32 static const TCHAR pipeNameFromSrv[] = __T("\\\\.\\pipe\\FromSrvPipe");
33
34 hPipeFromSrv = CreateNamedPipe(
35 pipeNameFromSrv ,
36 PIPE_ACCESS_DUPLEX,
37 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS,
38 PIPE_UNLIMITED_INSTANCES,
39 nBuff,
40 nBuff,
41 50,//Timeout - always send straight away.
42 NULL);
43 if( hPipeFromSrv == INVALID_HANDLE_VALUE)
44 return;
45
46 BOOL bConnected;
47 BOOL bSuccess;
48 DWORD cbBytesRead;
49 DWORD cbBytesWritten;
50 CHAR chRequest[ nBuff ];
51 CHAR chResponse[ nBuff ];
52
53 int jj=0;
54
55 for(;;)
56 {
57 // open to (incoming) pipe first.
58 printf( "Obtaining pipe\n" );
59 bConnected = ConnectNamedPipe(hPipeToSrv, NULL) ?
60 TRUE : (GetLastError()==ERROR_PIPE_CONNECTED );
61 printf( "Obtained to-srv %i\n", bConnected );
62
63 // open from (outgoing) pipe second. This could block if there is no reader.
64 bConnected = ConnectNamedPipe(hPipeFromSrv, NULL) ?
65 TRUE : (GetLastError()==ERROR_PIPE_CONNECTED );
66 printf( "Obtained from-srv %i\n", bConnected );
67
68 if( bConnected )
69 {
70 for(;;)

Callers 1

RegScriptServerFuncFunction · 0.85

Calls 2

DoSrvFunction · 0.85
DoSrvMoreFunction · 0.85

Tested by

no test coverage detected