IlsTcpMvProcess
 
IlsTcpMvProcess
Category 
Communication layer class
Inheritance Path 
IlsMvProcess
IlsTcpMvProcess
Description 
This class lets you initialize a server or a component process that uses Rogue Wave Server MvTCP as its communication layer. 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 JavaTM. This class is also used to communicate with the Rogue Wave Views logical mapper to retrieve logical mappings .
Library 
<mvtcp>
Header File 
#include <ilserver/mvtcp/tcpmvproc.h>
Synopsis 
class IlsTcpMvProcess : public IlsMvProcess{
 
protected:
IlsTcpMvProcess(unsigned short & listenPort);
Initialization
public:
static IlsBoolean Initialize
(int& argc,
char** argv,
unsigned short listenPort=0);
static unsigned short GetListenPort();
static void HideSendingErrors();
Buffers
static void SetDefaultRecvBuffer(int size);
static int GetDefaultRecvBuffer();
static void SetDefaultSendBuffer(int size);
static int GetDefaultSendBuffer();
Timeout
static IlsTime* GetTcpTimeout();
static void SetTcpTimeout(IlsTime * timeout);
static void SetTcpNoDelay(IlsBoolean b=IlsTrue);
static IlsBoolean IsTcpNoDelay();
File Descriptors
static IlsBoolean AddInput(unsigned int fd,
IlsSocketCallback cb,
IlsAny arg = 0);
static IlsBoolean RemoveInput(unsigned int fd);
static void ProcessFD(unsigned int fd);
static void SetCreateFDCallback(IlsSocketCallback cb, IlsAny);
static void SetRemoveFDCallback(IlsSocketCallback cb, IlsAny);
Communication with the Rogue Wave Views Logical Mappers
public:
static IlsTcpdMapping* GetMappings
(IlsString const & hostName,
int & size,
unsigned short port = 0,
IlsTime* timeout = 0);
static int PingDaemon(IlsString const & hostName,
unsigned short port = 0,
IlsTime* timeout = 0);
Trace
static void SetTrace(IlsBoolean b=IlsTrue);
IlsBoolean IsTraced();
Other Functions
virtual void onError
(const IlsString& msg,
IlsSocketException* e = 0,
IlsBoolean sendingError = IlsFalse);
virtual void onTcpError(const IlsString& msg);
virtual IlsBoolean processRequest(IlsTime* timeOut);
 
protected:
virtual unsigned short lookupProcess
(const IlsString& procName,
const IlsString& hostName);
virtual IlsTcpdMapping* getMappings
(IlsString const & hostName,
int & size,
unsigned short port = 0,
IlsTime * timeout = 0);
virtual int pingDaemon(IlsString const & hostName,
unsigned short port = 0,
IlsTime * timeout = 0);
};
Constructor 
protected IlsTcpMvProcess(unsigned short & listenPort);
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 listenPort argument.
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. The listenPort argument can be used to specify on which TCP port the process will listen to incoming messages.
[static] unsigned short GetListenPort();
This static member function returns the port used to accept new connections.
[static] void HideSendingErrors();
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.
Buffers
[static] void SetDefaultRecvBuffer(int size);
[static] int GetDefaultRecvBuffer();
Use these static member functions to set or get the default size of the receive buffer used by the sockets.
[static] void SetDefaultSendBuffer(int size);
[static] int GetDefaultSendBuffer();
Use these static member functions to set or get the default size of the receive buffer used by the sockets.
Timeout
[static] IlsTime* GetTcpTimeout();
[static] void SetTcpTimeout(IlsTime* timeout);
Use the appropriate static member functions to get or set the default timeout for synchronous calls.
[static] void SetTcpNoDelay(IlsBoolean b=IlsTrue);
This static member function sets the TCP_NO_DELAY option for sockets. This option is set by default on the platforms that supports it.
[static] IlsBoolean IsTcpNoDelay();
This static member function returns IlsTrue if the socket layer has been initialized with the TCP_NO_DELAY option on the platforms that supports it.
File Descriptors
[static] IlsBoolean AddInput(unsigned int fd,
IlsSocketCallback cb,
IlsAny arg = 0);
Use this static member function to 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.
[static] IlsBoolean RemoveInput(unsigned int fd);
Use this static member function to unregister an external file descriptor from the Rogue Wave Server MvTCP main loop.
[static] void ProcessFD(unsigned int 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.
[static] void SetCreateFDCallback(IlsSocketCallback cb, IlsAny);
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.
[static] void SetRemoveFDCallback(IlsSocketCallback cb, IlsAny);
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.
Communication with the Rogue Wave Views Logical Mapper
[static] IlsTcpdMapping* GetMappings(IlsString const & hostName,
int & size,
unsigned short port = 0,
IlsTime * timeout = 0);
This static member function 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.
[static] int PingDaemon(IlsString const & hostName,
unsigned short port = 0,
IlsTime * timeout = 0);
This static member function is used to know whether an 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).
This function returns one of the following values :
*0: The logical mapper is alive.
*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 an Rogue Wave Views logical mapper (ping protocol error).
Trace
[static] void SetTrace(IlsBoolean b=IlsTrue);
This static member functions set the trace mode for the MvTCP layer.
[static] IlsBoolean IsTraced();
This static member function returns IlsTrue if the trace mode for the MvTCP layer is enabled.
Other Functions
[virtual] void onError(const IlsString& msg,
IlsSocketException* e = 0,
IlsBoolean sendingError = IlsFalse);
This virtual member function is 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 Manual 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.
[virtual] void onTcpError(const IlsString& msg);
This virtual member function 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.
[virtual] IlsBoolean processRequest(IlsTime* timeOut);
This virtual member function is called by the function IlsMvServer::Run to execute a request issued by a component. This method returns IlsFalse if a timeout has been set (timeout 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.
Protected Member Functions 
[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. 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.
[virtual] IlsTcpdMapping* getMappings(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 an Rogue Wave Server logical mapper. See the static member function GetMappings.
[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. See the static member function PingDaemon.
See Also 
IlsIlvTcpMvProcess, IlsMvProcess, IlsTcpdMapping, IlsSocketCallback

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.