Server
API Reference Guide
Product Documentation:

Visualization Server
Documentation Home
List of all members | Public Member Functions | Protected Member Functions
IlsTcpMvProcess Class Reference

This class lets you initialize a server or a component process that uses Rogue Wave Server MvTCP as its communication layer. More...

#include <ilserver/mvtcp/tcpmvproc.h>

Inheritance diagram for IlsTcpMvProcess:
IlsMvProcess IlsIlvTcpMvProcess

Public Member Functions

virtual IlsBoolean processRequest (IlsTime *t)
 Called by the function IlsMvServer::Run() to execute a request issued by a component. More...
 
- Public Member Functions inherited from IlsMvProcess
 IlsMvProcess ()
 Constructor. More...
 
virtual ~IlsMvProcess ()
 The instance of IlsMvProcess is automatically destroyed by Rogue Wave Server when the process ends.
 
IlsMvEndPoint *const * getEndPoints (int &dim)
 Returns an array of all the end points created in the process. More...
 
virtual void beforeRequest ()
 Called by the subclass of IlsMvProcess before it a request received on the communication layer is processed. More...
 
virtual void afterRequest ()
 Called by the subclass of IlsMvProcess after a request received on the communication layer has been processed. More...
 

Static Public Member Functions

Initialization
static IlsBoolean Initialize (int &argc, char **argv, unsigned short listenPort=0)
 Use this static member function to initialize MvTCP, the Rogue Wave Server TCP/IP communication layer. More...
 
static unsigned short GetListenPort ()
 This static member function returns the port used to accept new connections. More...
 
static void HideSendingErrors (IlsBoolean b)
 This static member function should be called after Initialize(). More...
 
Buffers
static void SetDefaultRecvBuffer (int size)
 Set the default size of the receive buffer used by the sockets. More...
 
static int GetDefaultRecvBuffer ()
 Get the default size of the receive buffer used by the sockets. More...
 
static void SetDefaultSendBuffer (int size)
 Set the default size of the send buffer used by the sockets. More...
 
static int GetDefaultSendBuffer ()
 Get the default size of the send buffer used by the sockets. More...
 
Timeout
static IlsTimeGetTcpTimeout ()
 Get the default timeout for synchronous calls. More...
 
static void SetTcpTimeout (IlsTime *timeout)
 Set the default timeout for synchronous calls. More...
 
static void SetTcpNoDelay (IlsBoolean b=IlsTrue)
 Set the TCP_NO_DELAY option for sockets. More...
 
static IlsBoolean IsTcpNoDelay ()
 Check if socket layer has been initialized with the TCP_NO_DELAY option. More...
 
Communication with the Logical Mapper
static IlsTcpdMappingGetMappings (IlsString const &hostName, int &size, unsigned short port=0, IlsTime *timeout=0)
 Returns all the mappings registered on a Rogue Wave Server logical mapper. More...
 
static int PingDaemon (IlsString const &hostName, unsigned short port=0, IlsTime *timeout=0)
 This static member function is used to know whether a Rogue Wave Server logical mapper is alive. More...
 
Trace
static void SetTrace (IlsBoolean b=IlsTrue)
 Set the trace mode for the MvTCP layer. More...
 
static IlsBoolean IsTraced ()
 Check if the trace mode for the MvTCP layer is enabled. More...
 
File Descriptors
static IlsBoolean AddInput (IlsFD fd, IlsSocketCallback cb, IlsAny arg=0)
 Register external file descriptors with the Rogue Wave Server MvTCP main loop. More...
 
static IlsBoolean RemoveInput (IlsFD fd)
 Unregister an external file descriptor from the Rogue Wave Server MvTCP main loop. More...
 
static void ProcessFD (IlsFD fd)
 Call this static member function when you have registered MvTCP file descriptors with an external main loop and detected an event through the select() system call on this file descriptor. More...
 
static void SetCreateFDCallback (IlsSocketCallback cb, IlsAny arg=0)
 This static member function registers a callback that will be called each time a new MvTCP file descriptor must be registered with an external main loop. Call this function after having initialized the MvTCP layer using the Initialize function. More...
 
static void SetRemoveFDCallback (IlsSocketCallback cb, IlsAny arg=0)
 This static member function registers a callback that will be called each time MvTCP releases a file descriptor. If you have registered the MvTCP file descriptor passed to the callback with an external main loop, you must unregister it when the callback is called. More...
 
- Static Public Member Functions inherited from IlsMvProcess
static IlsMvProcessGetSingletonPtr ()
 Returns the single instance of IlsMvProcess that has been initialized or 0 if none has been initialized. More...
 
static IlsBoolean SetName (const IlsString &name)
 Assigns a name to the current process to enable distributed applications to connect to the process. More...
 
static IlsString GetName ()
 Returns the name assigned to the process or by default the null string.
 
static IlsBoolean Initialize (int &argc, char **argv)
 Initializes a linked Server process – that is, a process including both server and component(s). More...
 
static IlsBoolean IsInitialized ()
 Returns IlsTrue if the process has already been initialized or IlsFalse otherwise.
 
static IlsMvEndPointGetEndPoint (const IlsString &procName, const IlsString &hostName, IlsBoolean isComp)
 Returns a pointer to the local end point of the connection established with the process procName on host hostName. More...
 
static IlsMvComponentGetComponent (const IlsString &serverName, const IlsString &hostName)
 Similar to the function GetEndPoint(), except that it explicitly looks for a component connected to the server named serverName on host hostName.
 
static IlsMvEndPointConnect (const IlsString &actorName, const IlsString &hostName, const IlsString &myIPAddr=IlsString::Null, IlsBoolean toServer=IlsTrue)
 Enables connection to the process procName running on the host hostName. More...
 
static int DoConnect ()
 Executes the connection to the server(s) specified in the command line using one of the -ilsc or -ilsconnect options. More...
 
static IlsBoolean DisconnectOnComError ()
 Returns the value of the disconnectOnError property. More...
 
static void SetDisconnectOnComError (IlsBoolean b)
 Sets the value of the disconnectOnError property.
 
static IlsBoolean Run (int nb=0, IlsTime *t=0)
 Iimplements the default event loop for dynamic-view based processes. More...
 
static IlsBoolean ProcessRequest (IlsTime *t)
 Calls the virtual function processRequest() on the IlsMvProcess singleton.
 
static void Stop ()
 Stops the Run() event loop.
 

Protected Member Functions

 IlsTcpMvProcess (unsigned short &port)
 This protected constructor is called by the static member function Initialize or by the constructor of a subclass with the listen port as its argument. More...
 
virtual IlsTcpdMappinggetMappings (IlsString const &hostName, int &size, unsigned short port=0, IlsTime *timeout=0)
 You can override this virtual member function to define your own implementation, that is, to return a list of predefined mappings without connecting to a Rogue Wave Server logical mapper. More...
 
virtual IlsBoolean localInitialize (int &argc, char **argv)
 Invoked by the member function initialize. More...
 
virtual unsigned short lookupProcess (const IlsString &procName, const IlsString &hostName)
 By default, this virtual member function request the logical mapper running on hostName to get the TCP port of the server process. More...
 
virtual void onError (const IlsString &msg, IlsSocketException *e=0, IlsBoolean sendingError=IlsFalse)
 Invoked by Rogue Wave Server each time an exception is trapped inside the MvTCP communication layer or each time an error occurs when the connection is manipulated. More...
 
virtual void onTcpError (const IlsString &msg)
 Is invoked by Rogue Wave Server when a low-level error occurs in the MvTCP communication layer. More...
 
virtual int pingDaemon (IlsString const &hostName, unsigned short port=0, IlsTime *timeout=0)
 You can override this virtual member function to define your own implementation. More...
 
- Protected Member Functions inherited from IlsMvProcess
virtual IlsBoolean initialize (int &argc, char **argv)
 Initializes an instance of IlsMvProcess. More...
 

Detailed Description

This class lets you initialize a server or a component process that uses Rogue Wave Server MvTCP as its communication layer.

Library: mvtcp

For processes that use both Rogue Wave Server and Rogue Wave Views, you must use the class IlsIlvTcpMvProcess. The MvTCP communication layer is based on TCP/IP sockets and is available both in C++ and Java.

This class is also used to communicate with the Rogue Wave Server logical mapper to retrieve logical mappings.

See also
IlsIlvTcpMvProcess, IlsMvProcess, IlsTcpdMapping, IlsSocketCallback.

Constructor & Destructor Documentation

◆ IlsTcpMvProcess()

IlsTcpMvProcess::IlsTcpMvProcess ( unsigned short &  port)
protected

This protected constructor is called by the static member function Initialize or by the constructor of a subclass with the listen port as its argument.

The listen port is the port used to accept new connections. If the listen port is 0, Rogue Wave Server automatically selects an available port and assigns it to the port argument.

Parameters
portlisten port

Member Function Documentation

◆ AddInput()

static IlsBoolean IlsTcpMvProcess::AddInput ( IlsFD  fd,
IlsSocketCallback  cb,
IlsAny  arg = 0 
)
static

Register external file descriptors with the Rogue Wave Server MvTCP main loop.

When an event is detected on this file descriptor by the select() system call, Rogue Wave Server calls the corresponding callback with the provided argument arg.

Parameters
fdfile descriptor to add
cbsocket callback
arguser argument
Returns
IlsTrue if the file descriptor has been successfuly added.

◆ GetDefaultRecvBuffer()

static int IlsTcpMvProcess::GetDefaultRecvBuffer ( )
static

Get the default size of the receive buffer used by the sockets.

Returns
buffer size

◆ GetDefaultSendBuffer()

static int IlsTcpMvProcess::GetDefaultSendBuffer ( )
static

Get the default size of the send buffer used by the sockets.

Returns
buffer size

◆ GetListenPort()

static unsigned short IlsTcpMvProcess::GetListenPort ( )
static

This static member function returns the port used to accept new connections.

Returns
the listen port

◆ GetMappings()

static IlsTcpdMapping* IlsTcpMvProcess::GetMappings ( IlsString const &  hostName,
int &  size,
unsigned short  port = 0,
IlsTime timeout = 0 
)
static

Returns all the mappings registered on a Rogue Wave Server logical mapper.

The logical mapper is identified by the name of the machine on which it is running (the hostName parameter) and, optionally, by a port number. If the port number is equals to 0 the default port number is used. You can specify a timeout because this call is synchronous. If no timeout is specified it a blocking call (infinite timeout).

The return value is an IlsTcpdMapping array, whose size is returned in the size parameter.

Parameters
hostNamehost name of the logical mapper
sizereceive size of the returned array
portlogical mapper's port (0 for default port)
timeouttimeout (0 if no timeout)
Returns
IlsTcpdMapping array. You are responsible for deleting the array with delete [].

◆ getMappings()

virtual IlsTcpdMapping* IlsTcpMvProcess::getMappings ( IlsString const &  hostName,
int &  size,
unsigned short  port = 0,
IlsTime timeout = 0 
)
protectedvirtual

You can override this virtual member function to define your own implementation, that is, to return a list of predefined mappings without connecting to a Rogue Wave Server logical mapper.

See the static member function GetMappings().

Parameters
hostNamehost name of the logical mapper
sizereceive size of the returned array
portlogical mapper's port (0 for default port)
timeouttimeout (0 if no timeout)
Returns
IlsTcpdMapping array. You are responsible for deleting the array with delete [].

◆ GetTcpTimeout()

static IlsTime* IlsTcpMvProcess::GetTcpTimeout ( )
static

Get the default timeout for synchronous calls.

Returns
default timeout

◆ HideSendingErrors()

static void IlsTcpMvProcess::HideSendingErrors ( IlsBoolean  b)
static

This static member function should be called after Initialize().

It allows you to hide sending errors when the remote components has been deleted and before the disconnection is handled.

Parameters
bIlsTrue for hiding errors.

◆ Initialize()

static IlsBoolean IlsTcpMvProcess::Initialize ( int &  argc,
char **  argv,
unsigned short  listenPort = 0 
)
static

Use this static member function to initialize MvTCP, the Rogue Wave Server TCP/IP communication layer.

The listenPort argument can be used to specify on which TCP port the process will listen to incoming messages.

Parameters
argcthe argc received by main() function.
argvthe argv received by main() function.
listenPortlisten port
Returns
IlsTrue if initialization succeeded, IlsFalse otherwise.

◆ IsTcpNoDelay()

static IlsBoolean IlsTcpMvProcess::IsTcpNoDelay ( )
static

Check if socket layer has been initialized with the TCP_NO_DELAY option.

Returns
IlsTrue if the socket layer has been initialized with the TCP_NO_DELAY option on the platforms that supports it.

◆ IsTraced()

static IlsBoolean IlsTcpMvProcess::IsTraced ( )
static

Check if the trace mode for the MvTCP layer is enabled.

Returns
IlsTrue if trace mode is enabled.

◆ localInitialize()

virtual IlsBoolean IlsTcpMvProcess::localInitialize ( int &  argc,
char **  argv 
)
protectedvirtual

Invoked by the member function initialize.

It takes the arguments of the command line as its parameters. It has an empty body but is overridden in subclasses of IlsMvProcess.

Reimplemented from IlsMvProcess.

Reimplemented in IlsIlvTcpMvProcess.

◆ lookupProcess()

virtual unsigned short IlsTcpMvProcess::lookupProcess ( const IlsString procName,
const IlsString hostName 
)
protectedvirtual

By default, this virtual member function request the logical mapper running on hostName to get the TCP port of the server process.

It is called by Rogue Wave Server when the process attempts a connection to another process, named procName, on the machine hostName. If the method returns 0, the connection attempt fails.

Parameters
procNameserver name
hostNamehost name on which the server runs.
Returns
TCP port of the server. 0 if the connection fails.

◆ onError()

virtual void IlsTcpMvProcess::onError ( const IlsString msg,
IlsSocketException e = 0,
IlsBoolean  sendingError = IlsFalse 
)
protectedvirtual

Invoked by Rogue Wave Server each time an exception is trapped inside the MvTCP communication layer or each time an error occurs when the connection is manipulated.

See section Subclassing IlsTcpMvProcess in Appendix E of Rogue Wave Server User's Guide to learn how to override this method to trap MvTCP errors. The default behavior is to log a error message prefixed by MvTCP:.

  • If the error is the result of an exception that has been caught, that exception is passed as an argument to this method to provide a full description of the problem.
  • If the error occurs when messages of Rogue Wave Server Generic Protocol are sent, the sendingError parameter is set to IlsTrue. In this case, no error message is logged in the default implementation if the method HideSendingErrors() has been invoked on the process.
Parameters
msgerror message
eexception if any
sendingErrorIlsTrue if error occurs when messages of generic protocol are sent.

◆ onTcpError()

virtual void IlsTcpMvProcess::onTcpError ( const IlsString msg)
protectedvirtual

Is invoked by Rogue Wave Server when a low-level error occurs in the MvTCP communication layer.

By default, an error message prefixed by MvTCP (TCP): is logged.

Parameters
msgerror message

◆ PingDaemon()

static int IlsTcpMvProcess::PingDaemon ( IlsString const &  hostName,
unsigned short  port = 0,
IlsTime timeout = 0 
)
static

This static member function is used to know whether a Rogue Wave Server logical mapper is alive.

The logical mapper is identified by the name of the machine on which it is running (the hostName parameter) and, optionally, by a port number. You can specify a timeout value because this call is synchronous. If no timeout is specified, it is a blocking call (infinite timeout).

Parameters
hostNamehost name of the logical mapper
portlogical mapper's port (0 is the default port)
timeouttimeout (0 if no timeout)
Returns
0 if success. The possible errors are:
  • 1: There is no logical mapper running on the host machine (unable to establish a connection).
  • 2: There is no response of the logical mapper (timeout reached).
  • 3: There is a service running on the hostname and port number but is not a Rogue Wave Server logical mapper (ping protocol error).

◆ pingDaemon()

virtual int IlsTcpMvProcess::pingDaemon ( IlsString const &  hostName,
unsigned short  port = 0,
IlsTime timeout = 0 
)
protectedvirtual

You can override this virtual member function to define your own implementation.

See the static member function PingDaemon().

Parameters
hostNamehost name of the logical mapper
portlogical mapper's port (0 is the default port)
timeouttimeout (0 if no timeout)
Returns
0 if success. The possible errors are:
  • 1: There is no logical mapper running on the host machine (unable to establish a connection).
  • 2: There is no response of the logical mapper (timeout reached).
  • 3: There is a service running on the hostname and port number but is not a Rogue Wave Server logical mapper (ping protocol error).

◆ ProcessFD()

static void IlsTcpMvProcess::ProcessFD ( IlsFD  fd)
static

Call this static member function when you have registered MvTCP file descriptors with an external main loop and detected an event through the select() system call on this file descriptor.

Parameters
fdfile descriptor to process

◆ processRequest()

virtual IlsBoolean IlsTcpMvProcess::processRequest ( IlsTime t)
virtual

Called by the function IlsMvServer::Run() to execute a request issued by a component.

This method returns IlsFalse if a timeout has been set (t parameter != 0) and has expired before an event has been received on the communication layer, or if a low-level exception is raised by the communication layer. In this case, an error message is issued.

Parameters
ttimeout (0 for no timeout)
Returns
IlsFalse if timeout expires before an event has been received or if an exception has been catched.

Reimplemented from IlsMvProcess.

◆ RemoveInput()

static IlsBoolean IlsTcpMvProcess::RemoveInput ( IlsFD  fd)
static

Unregister an external file descriptor from the Rogue Wave Server MvTCP main loop.

Parameters
fdfile descriptor to remove
Returns
IlsTrue if the file descriptor has been successfuly removed.

◆ SetCreateFDCallback()

static void IlsTcpMvProcess::SetCreateFDCallback ( IlsSocketCallback  cb,
IlsAny  arg = 0 
)
static

This static member function registers a callback that will be called each time a new MvTCP file descriptor must be registered with an external main loop. Call this function after having initialized the MvTCP layer using the Initialize function.

You must call the member function ProcessFD() when the external main loop has detected an event on this file descriptor through the select() system call. When this function is called, Rogue Wave Server will immediately trigger the callback you provided for the listen file descriptor of MvTCP.

Parameters
cbcallback to be called
arguser argument

◆ SetDefaultRecvBuffer()

static void IlsTcpMvProcess::SetDefaultRecvBuffer ( int  size)
static

Set the default size of the receive buffer used by the sockets.

Parameters
sizebuffer size

◆ SetDefaultSendBuffer()

static void IlsTcpMvProcess::SetDefaultSendBuffer ( int  size)
static

Set the default size of the send buffer used by the sockets.

Parameters
sizebuffer size

◆ SetRemoveFDCallback()

static void IlsTcpMvProcess::SetRemoveFDCallback ( IlsSocketCallback  cb,
IlsAny  arg = 0 
)
static

This static member function registers a callback that will be called each time MvTCP releases a file descriptor. If you have registered the MvTCP file descriptor passed to the callback with an external main loop, you must unregister it when the callback is called.

Parameters
cbcallback to be called
arguser argument

◆ SetTcpNoDelay()

static void IlsTcpMvProcess::SetTcpNoDelay ( IlsBoolean  b = IlsTrue)
static

Set the TCP_NO_DELAY option for sockets.

This option is set by default on the platforms that supports it.

Parameters
bIlsTrue to set the TCP_NO_DELAY option.

◆ SetTcpTimeout()

static void IlsTcpMvProcess::SetTcpTimeout ( IlsTime timeout)
static

Set the default timeout for synchronous calls.

Parameters
timeoutnew default timeout

◆ SetTrace()

static void IlsTcpMvProcess::SetTrace ( IlsBoolean  b = IlsTrue)
static

Set the trace mode for the MvTCP layer.

Parameters
bIlsTrue to set traces. IlsFalse for no trace.