Barst  2.0
A server that controls lab hardware.
Public Member Functions | List of all members
CPipeServer Class Reference

#include <named pipes.h>

Inheritance diagram for CPipeServer:
CComm

Public Member Functions

int Init (const TCHAR szPipe[], int nPipes, DWORD dwBuffSizeIn, DWORD dwBuffSizeOut, CDevice *cDevice, CLogBuffer *cLogBuffer)
 
int SendData (const SData *pData, __int64 llId)
 
void Close ()
 
DWORD ThreadProc ()
 

Additional Inherited Members

- Protected Attributes inherited from CComm
CDevicem_pcDevice
 
CLogBufferm_pcLogBuffer
 
CMemPoolm_pcMemPool
 

Detailed Description

Implememts named pipes as a comm. Communication is async so that one thread is doing all the work async. But, you can have multiple clients connecting simultaneuosly. You call init to start the server and close to stop it. Closing stopps all current communications.

Definition at line 98 of file named pipes.h.

Member Function Documentation

◆ Close()

void CPipeServer::Close ( )
virtual

Stops all communication with this comm, terminates all threads and returns it to its original state. Any data waiting to be sent is not sent but Result() is called on that data.

Implements CComm.

Definition at line 402 of file named pipes.cpp.

◆ Init()

int CPipeServer::Init ( const TCHAR  szPipe[],
int  nPipes,
DWORD  dwBuffSizeIn,
DWORD  dwBuffSizeOut,
CDevice cDevice,
CLogBuffer cLogBuffer 
)

szPipe is the pipe to be used. nPipes is the maximum number of pipes instances that can be open at once. For instance, if it's 1, only one user can connect at any time. The maximum actually possible instances is in the 30s. If all the pipes are connected to users, another client trying to connect will get a busy error reply. dwBuffSizeIn is the max buffer that can be written by the client to the server at once. dwBuffSizeOut is the max buffer that can be read by the client and written by the server at once. cDevice is the device that this pipe will call when a client writes to the pipe. cLogBuffer is NULL currently, but would contain a log object. If g_llMaxQueueBytes is not -1, data which would result in larger values than g_llMaxQueueBytes will be simply discarded without error.

Definition at line 75 of file named pipes.cpp.

◆ SendData()

int CPipeServer::SendData ( const SData pData,
__int64  llId 
)
virtual

Sends data to a user identified by llId. Function returns TRUE if it failed and FALSE otherwise. At some point it could be extended to return an error code if needed.

Implements CComm.

Definition at line 437 of file named pipes.cpp.