ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbSIO Class Reference

#include <ngcbSIO.hpp>

Inheritance diagram for ngcbSIO:
_app ngcbIFC_TCP ngcbTCP2DRV ngcdcsDTT_COM ngcdcsMRGEVT ngcdcsSRV

Public Member Functions

 ngcbSIO ()
 Constructor.
 
virtual ~ngcbSIO ()
 Destructor.
 
char * ErrMsg ()
 Error message.
 
int PortNum (int fd)
 Get port number.
 
int GetIpAddr (const char *name, char *ipAddr)
 Get IP-address.
 
int WaitSocket (int fd, int timeout)
 Wait with timeout until socket becomes readable.
 
int TcpService (const char *service=NULL)
 Open a tcp/ip server socket.
 
int TcpService (int port)
 Open a tcp/ip server socket.
 
int TcpAccept (int srvSocket)
 Accept a tcp/ip connection request from a client.
 
int TcpConnect (const char *service)
 Connect to a tcp/ip socket service.
 
int TcpConnect (int port, const char *host=NULL)
 Connect to a tcp/ip socket service defined by port and host.
 
int TcpClose (int fd)
 Close tcp/ip socket.
 
int TcpRead (int fd, void *buffer, size_t size)
 Read buffer from tcp/ip socket.
 
int TcpWrite (int fd, const void *buffer, size_t size)
 Write buffer to tcp/ip socket.
 
int TcpPuts (int fd, const char *string)
 Put string to tcp/ip socket.
 
int TcpGets (int fd, char *string, int maxLen)
 Get string from tcp/ip socket.
 
int TcpReadRequest (int fd, char *request, int maxSize)
 Read request from tcp/ip socket.
 
int TcpWriteReply (int fd, const char *reply, int success)
 Write reply to tcp/ip socket.
 
int ExecVersion (const char *host)
 Return version of exec daemon or -1 if version cannot be retrieved.
 
int Exec (const char *host, const char *cmd, char *reply, int port=0)
 Execute process on host.
 
int ExecXt (const char *host, const char *cmd, char *reply, const char *geom=NULL)
 Execute process on host (in new terminal)
 
int Kill (const char *host, int pid)
 Terminate process on host.
 
void ExecReply (int fd, char success, const char *reply)
 Send reply to calling process.
 
int Discover (const char *host, const char *name, const char *instance, int *port, int *protocol=NULL)
 Discover command/reply service on host.
 
int Discover (const char *name, const char *instance, int *port, int *protocol=NULL)
 Discover command/reply service on local host.
 
int Connect (const char *host, int port, int protocol, int *evtPort)
 Connect client to command/reply service.
 
int Connect (const char *host, int port, int protocol)
 Connect to command/reply service with specific protocol.
 
int Connect (const char *service, int protocol=ngcbSIO_PROTOCOL_ASCII)
 Connect to command/reply service with specific protocol.
 
void Disconnect ()
 Disconnect from command/reply service.
 
int Connected ()
 Return client connection status.
 
void ReplyBufferSize (size_t size)
 Set reply buffer size of the client interface.
 
int SendRequest (const char *request)
 Send request to server.
 
int GetReply (char *s=NULL)
 Copy reply from server to string.
 
int PrintReply (FILE *fd)
 Print server reply to stream.
 
int ReplyLine (char *line)
 Read next reply line.
 
char * Reply ()
 Reply buffer.
 
int RequestReply (const char *request, char *reply=NULL)
 Run request/reply protocol.
 
int OpenServer (int cmdPort, int evtPort=-1)
 Open socket server.
 
void CloseServer ()
 Close socket server.
 
void StopServer ()
 Terminate server main-loop.
 
int SrvOpened ()
 Returns 1 when server is open.
 
virtual void SetSrvAborted (int flag)
 Set server-aborted flag.
 
virtual int SrvAborted ()
 Returns 1 when server-aborted flag is set.
 
int SrvCmdPort ()
 Get actual server command port.
 
int SrvEvtPort ()
 Get actual server event port.
 
int SrvCmdSocket ()
 Get actual command server socket.
 
int SrvEvtSocket ()
 Get actual event server socket.
 
int OpenPort (int port, int protocol=0)
 Open service port.
 
int ClosePort (int port)
 Close service port.
 
int Port2Fd (int port)
 Return server socket associated to service port.
 
int Fd2Port (int fd)
 Return service port associated to server socket.
 
int ConnectCmd (int srvSocket, int protocol=0)
 Connect command client.
 
int NumCmdClient ()
 Return number of command client connections.
 
int HaveCmdClient ()
 Returns 1 in case any command client connection is established.
 
int ConnectEvt (int srvSocket)
 Connect event client.
 
int NumEvtClient ()
 Return number of event client connections.
 
int HaveEvtClient ()
 Returns 1 in case any event client connection is established.
 
void Broadcast (const void *buffer, size_t size)
 Broadcat buffer to all event clients.
 
void Broadcast (const char *s)
 Broadcast string to all event clients.
 
int Protocol (int fd)
 Run protocol when socket becomes readable.
 
int ProtocolType ()
 Get preferred protocol type.
 
void ProtocolType (int protocol)
 Set Protocol type.
 
int GetProtocol (int fd)
 Get protocol type assigned to a given socket.
 
void EnableStdIn ()
 Enable input via stdin.
 
void DisableStdIn ()
 Disable input via stdin.
 
int StdIn ()
 Get file-descriptor associated to the standard input.
 
int FdAttach (int fd)
 Attach file-descriptor to the file descriptor event call-back.
 
void FdDetach (int fd)
 Detach file-descriptor from the file descriptor event call-back.
 
void TimerSet (int ms)
 Set timer (in milliseconds)
 
void TimerOn ()
 Enable timer.
 
void TimerOff ()
 Stop timmer.
 
int MainLoop ()
 Enter socket server main-loop.
 
void Lock ()
 Lock service main-loop.
 
void Unlock ()
 Unlock service main-loop.
 
void CleanupCmd (char *cmdLine, int *cmdLen)
 Clean command string (remove extra spaces etc.)
 
virtual void Verbose (const char *format,...) __attribute__((format(printf
 Verbose output function.
 
virtual void virtual void Verbose (int level, const char *format,...) __attribute__((format(printf
 Verbose output function.
 
virtual void virtual void virtual void Log (const char *format,...) __attribute__((format(printf
 Logging function.
 
virtual void virtual void virtual void virtual void Log (int level, const char *format,...) __attribute__((format(printf
 Logging function.
 
virtual void virtual void virtual void virtual void virtual void LogMsg (const char *msg)
 Message logger.
 

Public Attributes

int verboseLevel
 Verbose level.
 
int logLevel
 Loggin level.
 
int ignoreSignal
 Ignore signal in main-loop select call.
 

Protected Member Functions

virtual int ProtocolBin (int fd)
 Binary protocol implementation.
 
virtual int ProtocolAscii (int fd)
 ASCII protocol implementation.
 
virtual int Service (int fd, int protocol)
 Application specific service protocol.
 
virtual int ServiceConnect (int fd, int protocol)
 Application specific service connection protocol.
 
virtual void ProtocolErr (const char *erms)
 Call-back to log protocol errors.
 
virtual int RegisterService (int fd)
 Register command service.
 
virtual int UnregisterService (int fd)
 Unregister command service.
 
virtual int NewEventConnection (int fd)
 Call-back for new event client connection.
 
virtual int FdCB (int fd)
 File descriptor event call-back.
 
virtual int TimerCB ()
 Call-back when time expires.
 
virtual void MainLoopInit ()
 Indicate main-loop initialization.
 

Detailed Description

Socket i/o service class

Constructor & Destructor Documentation

◆ ngcbSIO()

ngcbSIO::ngcbSIO ( )

Constructor.

◆ ~ngcbSIO()

ngcbSIO::~ngcbSIO ( )
virtual

Destructor.

Member Function Documentation

◆ Broadcast() [1/2]

void ngcbSIO::Broadcast ( const char * s)

Broadcast string to all event clients.

◆ Broadcast() [2/2]

void ngcbSIO::Broadcast ( const void * buffer,
size_t size )

Broadcat buffer to all event clients.

◆ CleanupCmd()

void ngcbSIO::CleanupCmd ( char * cmdLine,
int * cmdLen )

Clean command string (remove extra spaces etc.)

◆ ClosePort()

int ngcbSIO::ClosePort ( int port)

Close service port.

◆ CloseServer()

void ngcbSIO::CloseServer ( )

Close socket server.

◆ Connect() [1/3]

int ngcbSIO::Connect ( const char * host,
int port,
int protocol )

Connect to command/reply service with specific protocol.

◆ Connect() [2/3]

int ngcbSIO::Connect ( const char * host,
int port,
int protocol,
int * evtPort )

Connect client to command/reply service.

◆ Connect() [3/3]

int ngcbSIO::Connect ( const char * service,
int protocol = ngcbSIO_PROTOCOL_ASCII )

Connect to command/reply service with specific protocol.

◆ ConnectCmd()

int ngcbSIO::ConnectCmd ( int srvSocket,
int protocol = 0 )

Connect command client.

◆ Connected()

int ngcbSIO::Connected ( )

Return client connection status.

◆ ConnectEvt()

int ngcbSIO::ConnectEvt ( int srvSocket)

Connect event client.

◆ DisableStdIn()

void ngcbSIO::DisableStdIn ( )

Disable input via stdin.

◆ Disconnect()

void ngcbSIO::Disconnect ( )

Disconnect from command/reply service.

◆ Discover() [1/2]

int ngcbSIO::Discover ( const char * host,
const char * name,
const char * instance,
int * port,
int * protocol = NULL )

Discover command/reply service on host.

◆ Discover() [2/2]

int ngcbSIO::Discover ( const char * name,
const char * instance,
int * port,
int * protocol = NULL )

Discover command/reply service on local host.

◆ EnableStdIn()

void ngcbSIO::EnableStdIn ( )

Enable input via stdin.

◆ ErrMsg()

char * ngcbSIO::ErrMsg ( )
inline

Error message.

◆ Exec()

int ngcbSIO::Exec ( const char * host,
const char * cmd,
char * reply,
int port = 0 )

Execute process on host.

◆ ExecReply()

void ngcbSIO::ExecReply ( int fd,
char success,
const char * reply )

Send reply to calling process.

◆ ExecVersion()

int ngcbSIO::ExecVersion ( const char * host)

Return version of exec daemon or -1 if version cannot be retrieved.

◆ ExecXt()

int ngcbSIO::ExecXt ( const char * host,
const char * cmd,
char * reply,
const char * geom = NULL )

Execute process on host (in new terminal)

◆ Fd2Port()

int ngcbSIO::Fd2Port ( int fd)

Return service port associated to server socket.

◆ FdAttach()

int ngcbSIO::FdAttach ( int fd)

Attach file-descriptor to the file descriptor event call-back.

◆ FdCB()

int ngcbSIO::FdCB ( int fd)
protectedvirtual

File descriptor event call-back.

Reimplemented in ngcdcsMRGEVT, and ngcdcsSRV.

◆ FdDetach()

void ngcbSIO::FdDetach ( int fd)

Detach file-descriptor from the file descriptor event call-back.

◆ GetIpAddr()

int ngcbSIO::GetIpAddr ( const char * name,
char * ipAddr )

Get IP-address.

◆ GetProtocol()

int ngcbSIO::GetProtocol ( int fd)

Get protocol type assigned to a given socket.

◆ GetReply()

int ngcbSIO::GetReply ( char * s = NULL)

Copy reply from server to string.

◆ HaveCmdClient()

int ngcbSIO::HaveCmdClient ( )

Returns 1 in case any command client connection is established.

◆ HaveEvtClient()

int ngcbSIO::HaveEvtClient ( )

Returns 1 in case any event client connection is established.

◆ Kill()

int ngcbSIO::Kill ( const char * host,
int pid )

Terminate process on host.

◆ Lock()

void ngcbSIO::Lock ( )

Lock service main-loop.

◆ Log() [1/2]

void ngcbSIO::Log ( const char * format,
... )
virtual

Logging function.

Reimplemented in ngcbTCP2DRV, and ngcdcsSRV.

◆ Log() [2/2]

void ngcbSIO::Log ( int level,
const char * format,
... )
virtual

Logging function.

Reimplemented in ngcdcsSRV.

◆ LogMsg()

void ngcbSIO::LogMsg ( const char * msg)
virtual

Message logger.

◆ MainLoop()

int ngcbSIO::MainLoop ( )

Enter socket server main-loop.

◆ MainLoopInit()

void ngcbSIO::MainLoopInit ( )
protectedvirtual

Indicate main-loop initialization.

Reimplemented in _app.

◆ NewEventConnection()

int ngcbSIO::NewEventConnection ( int fd)
protectedvirtual

Call-back for new event client connection.

Reimplemented in ngcdcsSRV.

◆ NumCmdClient()

int ngcbSIO::NumCmdClient ( )

Return number of command client connections.

◆ NumEvtClient()

int ngcbSIO::NumEvtClient ( )

Return number of event client connections.

◆ OpenPort()

int ngcbSIO::OpenPort ( int port,
int protocol = 0 )

Open service port.

◆ OpenServer()

int ngcbSIO::OpenServer ( int cmdPort,
int evtPort = -1 )

Open socket server.

◆ Port2Fd()

int ngcbSIO::Port2Fd ( int port)

Return server socket associated to service port.

◆ PortNum()

int ngcbSIO::PortNum ( int fd)

Get port number.

◆ PrintReply()

int ngcbSIO::PrintReply ( FILE * fd)

Print server reply to stream.

◆ Protocol()

int ngcbSIO::Protocol ( int fd)

Run protocol when socket becomes readable.

◆ ProtocolAscii()

int ngcbSIO::ProtocolAscii ( int fd)
protectedvirtual

ASCII protocol implementation.

Reimplemented in _app, and ngcdcsSRV.

◆ ProtocolBin()

int ngcbSIO::ProtocolBin ( int fd)
protectedvirtual

Binary protocol implementation.

Reimplemented in ngcbTCP2DRV, ngcdcsMRGEVT, and ngcdcsSRV.

◆ ProtocolErr()

void ngcbSIO::ProtocolErr ( const char * erms)
protectedvirtual

Call-back to log protocol errors.

◆ ProtocolType() [1/2]

int ngcbSIO::ProtocolType ( )

Get preferred protocol type.

◆ ProtocolType() [2/2]

void ngcbSIO::ProtocolType ( int protocol)

Set Protocol type.

◆ RegisterService()

int ngcbSIO::RegisterService ( int fd)
protectedvirtual

Register command service.

◆ Reply()

char * ngcbSIO::Reply ( )
inline

Reply buffer.

◆ ReplyBufferSize()

void ngcbSIO::ReplyBufferSize ( size_t size)

Set reply buffer size of the client interface.

◆ ReplyLine()

int ngcbSIO::ReplyLine ( char * line)

Read next reply line.

◆ RequestReply()

int ngcbSIO::RequestReply ( const char * request,
char * reply = NULL )

Run request/reply protocol.

◆ SendRequest()

int ngcbSIO::SendRequest ( const char * request)

Send request to server.

◆ Service()

int ngcbSIO::Service ( int fd,
int protocol )
protectedvirtual

Application specific service protocol.

◆ ServiceConnect()

int ngcbSIO::ServiceConnect ( int fd,
int protocol )
protectedvirtual

Application specific service connection protocol.

◆ SetSrvAborted()

void ngcbSIO::SetSrvAborted ( int flag)
virtual

Set server-aborted flag.

Reimplemented in _app.

◆ SrvAborted()

int ngcbSIO::SrvAborted ( )
virtual

Returns 1 when server-aborted flag is set.

Reimplemented in _app.

◆ SrvCmdPort()

int ngcbSIO::SrvCmdPort ( )

Get actual server command port.

◆ SrvCmdSocket()

int ngcbSIO::SrvCmdSocket ( )

Get actual command server socket.

◆ SrvEvtPort()

int ngcbSIO::SrvEvtPort ( )

Get actual server event port.

◆ SrvEvtSocket()

int ngcbSIO::SrvEvtSocket ( )

Get actual event server socket.

◆ SrvOpened()

int ngcbSIO::SrvOpened ( )

Returns 1 when server is open.

◆ StdIn()

int ngcbSIO::StdIn ( )

Get file-descriptor associated to the standard input.

◆ StopServer()

void ngcbSIO::StopServer ( )

Terminate server main-loop.

◆ TcpAccept()

int ngcbSIO::TcpAccept ( int srvSocket)

Accept a tcp/ip connection request from a client.

◆ TcpClose()

int ngcbSIO::TcpClose ( int fd)

Close tcp/ip socket.

◆ TcpConnect() [1/2]

int ngcbSIO::TcpConnect ( const char * service)

Connect to a tcp/ip socket service.

◆ TcpConnect() [2/2]

int ngcbSIO::TcpConnect ( int port,
const char * host = NULL )

Connect to a tcp/ip socket service defined by port and host.

◆ TcpGets()

int ngcbSIO::TcpGets ( int fd,
char * string,
int maxLen )

Get string from tcp/ip socket.

◆ TcpPuts()

int ngcbSIO::TcpPuts ( int fd,
const char * string )

Put string to tcp/ip socket.

◆ TcpRead()

int ngcbSIO::TcpRead ( int fd,
void * buffer,
size_t size )

Read buffer from tcp/ip socket.

◆ TcpReadRequest()

int ngcbSIO::TcpReadRequest ( int fd,
char * request,
int maxSize )

Read request from tcp/ip socket.

◆ TcpService() [1/2]

int ngcbSIO::TcpService ( const char * service = NULL)

Open a tcp/ip server socket.

◆ TcpService() [2/2]

int ngcbSIO::TcpService ( int port)

Open a tcp/ip server socket.

◆ TcpWrite()

int ngcbSIO::TcpWrite ( int fd,
const void * buffer,
size_t size )

Write buffer to tcp/ip socket.

◆ TcpWriteReply()

int ngcbSIO::TcpWriteReply ( int fd,
const char * reply,
int success )

Write reply to tcp/ip socket.

◆ TimerCB()

int ngcbSIO::TimerCB ( )
protectedvirtual

Call-back when time expires.

Reimplemented in ngcbTCP2DRV, and ngcdcsSRV.

◆ TimerOff()

void ngcbSIO::TimerOff ( )

Stop timmer.

◆ TimerOn()

void ngcbSIO::TimerOn ( )

Enable timer.

◆ TimerSet()

void ngcbSIO::TimerSet ( int ms)

Set timer (in milliseconds)

◆ Unlock()

void ngcbSIO::Unlock ( )

Unlock service main-loop.

◆ UnregisterService()

int ngcbSIO::UnregisterService ( int fd)
protectedvirtual

Unregister command service.

◆ Verbose() [1/2]

void ngcbSIO::Verbose ( const char * format,
... )
virtual

Verbose output function.

Reimplemented in ngcbTCP2DRV, and ngcdcsSRV.

◆ Verbose() [2/2]

void ngcbSIO::Verbose ( int level,
const char * format,
... )
virtual

Verbose output function.

Reimplemented in ngcdcsSRV.

◆ WaitSocket()

int ngcbSIO::WaitSocket ( int fd,
int timeout )

Wait with timeout until socket becomes readable.

Member Data Documentation

◆ ignoreSignal

int ngcbSIO::ignoreSignal

Ignore signal in main-loop select call.

◆ logLevel

int ngcbSIO::logLevel

Loggin level.

◆ verboseLevel

int ngcbSIO::verboseLevel

Verbose level.


The documentation for this class was generated from the following files: