MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / createPendingServerInstance

Function createPendingServerInstance

Libraries/File/File.cpp:1207–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1205}
1206
1207static Result createPendingServerInstance(StringSpan pipeName, const NamedPipeServerOptions& options,
1208 bool firstInstance, FileDescriptor& pendingConnection)
1209{
1210 const wchar_t* nullTerminatedName = pipeName.getNullTerminatedNative();
1211
1212 DWORD openMode = PIPE_ACCESS_DUPLEX;
1213 if (not options.connectionOptions.blocking)
1214 {
1215 openMode |= FILE_FLAG_OVERLAPPED;
1216 }
1217 if (firstInstance)
1218 {
1219 openMode |= FILE_FLAG_FIRST_PIPE_INSTANCE;
1220 }
1221
1222 DWORD maxPendingConnections = options.maxPendingConnections;
1223 if (maxPendingConnections == 0)
1224 {
1225 maxPendingConnections = 1;
1226 }
1227 if (maxPendingConnections > PIPE_UNLIMITED_INSTANCES)
1228 {
1229 maxPendingConnections = PIPE_UNLIMITED_INSTANCES;
1230 }
1231
1232 const DWORD pipeMode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
1233
1234 HANDLE handle =
1235 ::CreateNamedPipeW(nullTerminatedName, openMode, pipeMode, maxPendingConnections, 65536, 65536, 0, nullptr);
1236 SC_TRY_MSG(handle != INVALID_HANDLE_VALUE, "NamedPipeServer::create CreateNamedPipeW failed");
1237
1238 return Result(pendingConnection.assign(handle));
1239}
1240} // namespace
1241
1242SC::Result SC::NamedPipeServer::create(StringSpan pipeName, NamedPipeServerOptions pipeOptions)

Callers 2

createMethod · 0.85
acceptMethod · 0.85

Calls 2

ResultClass · 0.50
assignMethod · 0.45

Tested by

no test coverage detected