In file AppServer/AppServer.hh:

class AppServer

Application server class

Inheritance:


Public Methods

AppServer (const char* Name=0, long ofl=o_none, lmsg::NameProcs Typ=p_Any)
Construct a server.
virtual ~AppServer (void)
destroy the server.
void addHandler (MsgHeader::MsgType type, MsgHandler* handle)
Specify a message handler.
error_type close (void)
Close the server socket.
error_type handleMessage (void)
Read a message and handle it.
error_type open (long flags)
Open the server socket.
error_type receive (MsgHeader& hdr, void* data, size_type length, double timeout)
Receive a message.
error_type receive (MsgHeader& hdr, void* data, size_type length)
Receive a message.
error_type reply (const MsgHeader& to, const Message& data)
Reply to a client request.
error_type reply (const MsgHeader& to, const MsgHeader& rhdr, const void* data)
Reply to a client request.
error_type send (const MsgHeader& hdr, const Message& msg)
Send a message to a peer.
error_type send (const MsgHeader& hdr, const void* data)
Send a message to a peer.
bool waitMsg (wtime_type time)
Wait for a message to arrive.
bool isOpen (void) const
Test is socket is open.
bool isRegistered (void) const
Test is server name is registered.
wtime_type getTimeOut (void) const
Get the default wait time.
index_type getDebug (void) const
Debug level.
error_type register_name (const char* server, NameProcs type=p_Any)
Register the server name.
void setDebug (index_type debug)
Set the debug level
void setDomainName (const char* domain)
Specify the name of the local name server
void setServerPort (const MsgAddr& addr)
Specify the server address
void setTimeOut (wtime_type time)
Get the default wait time.

Documentation

AppServer provides a server API for the LIGO/DMT messaging system.
AppServer(const char* Name=0, long ofl=o_none, lmsg::NameProcs Typ=p_Any)
Construct an message server and optionally register it with the local name server.
Parameters:
Name - Server name.
ofl - Open flags.
Typ - Server type.

virtual ~AppServer(void)
Destroy the server. Unregister its name and release the socket and addresss.

void addHandler(MsgHeader::MsgType type, MsgHandler* handle)
Add a message type to the server handler list, with a pointer to the appropriate handler.
Parameters:
type - Message type to be handled.
handle - Message handler pointer.

error_type close(void)
Close the socket used by the server and unregister the server name if one has been registered.

error_type handleMessage(void)
Read in a message and process it with the appropriate handler.
Returns:
Lmsg error code.

error_type open(long flags)
Open a socket for this server and bind it to an available IP address. Register the server name if one has been specified and the o_register flag was set. SIGIO exceptions are also enabled on the socket if the o_async flag is set.
Returns:
Lmsg error code.
Parameters:
flags - Bit mask indicating optional processing to be performed.

error_type receive(MsgHeader& hdr, void* data, size_type length, double timeout)
Receive a message. The message header is returned in hdr and the message text is returned in data. If no message is received in 'timeout' seconds receive will return with a TimeOut error.
Returns:
Lmsg standard error code.
Parameters:
hdr - Buffer to receive the mesage header.
data - Buffer to receive the message text.
length - Length of the message text buffer in bytes.
timeout - Maximum wait time in seconds.

error_type receive(MsgHeader& hdr, void* data, size_type length)
Receive a message. The message header is returned in hdr and the message text is returned in data. If no message is received in within the period specified with setTimeOut, receive will return with a TimeOut error.
Returns:
Lmsg standard error code.
Parameters:
hdr - Buffer to receive the mesage header.
data - Buffer to receive the message text.
length - Length of the message text buffer in bytes.

error_type reply(const MsgHeader& to, const Message& data)
A reply message is sent to the requesting client address with the correct transaction identifier. The request message header should be used as the 'to' argument for the reply.
Returns:
lmsg standard error codes.
Parameters:
to - Header of the request message.
data - Reply message.

error_type reply(const MsgHeader& to, const MsgHeader& rhdr, const void* data)
A reply message is sent to the requesting client address with the correct transaction identifier. The request message header should be used as the 'to' argument for the reply.
Returns:
lmsg standard error codes.
Parameters:
to - Header of the request message.
rhdr - Reply message header.
data - Pointer to the reply message text.

error_type send(const MsgHeader& hdr, const Message& msg)
Send a message to a peer process. The send method transmits messages from the server port and unlike the client request (see AppClient) doesn't wait for a message in reply.
Returns:
Lmsg standard error codes.
Parameters:
hdr - Header containing destination address of message.
msg - Message to be sent.

error_type send(const MsgHeader& hdr, const void* data)
Send a message to a peer process. The send method transmits messages from the server port and unlike the client request (see AppClient) doesn't wait for a message in reply.
Returns:
Lmsg standard error codes.
Parameters:
hdr - Header of message to be sent.
data - Text of message to be sent.

bool waitMsg(wtime_type time)
Wait for a message to arrive. If a message arrives in the specified maximum wait time, waitMsg() returns true. Otherwise false is returned. The message is left unread in the system input buffer. WaitMsg will return false when a signal is caaught before the time expires. The wait time is specified as for the default timeout period: a zero time results in an immediate return and a negative time results in waiting indefinitely until a message is received or a signal is caught.
Returns:
true if the message has arrived.
Parameters:
time - Maximum time to Wait for a message.

bool isOpen(void) const
Test whether the server socket is open.
Returns:
true if socket is open.

bool isRegistered(void) const
Test whether the server socket name has been registered with the name server.
Returns:
true if socket is registered.

wtime_type getTimeOut(void) const
Get the default maximum wait time in seconds.
Returns:
the default wait time in seconds.

index_type getDebug(void) const
Get the current debug level.
Returns:
Current debugging level.

error_type register_name(const char* server, NameProcs type=p_Any)
Register the server with the given name. If the server is already registered with a different name, it is unregistered and reregistered with the new name.
Parameters:
server - name to register.

void setDebug(index_type debug)
Set the debug level

void setDomainName(const char* domain)
Specify the name of the local name server

void setServerPort(const MsgAddr& addr)
Specify the server address

void setTimeOut(wtime_type time)
Set the default maximum wait time in seconds. If the wait time is set to zero, all functions using the default time will return TimeOut if a message is not immediately available. If the time is negative, the functions using the default will not return until a message is received or until the function is interrupted by a signel.
Parameters:
time - he default wait time in seconds.


This class has no child classes.
Author:
John Zweizig.
Version:
1.2; Modified May 17, 2002

alphabetic index hierarchy of classes


Please send questions and comments to zweizig_j@ligo.caltech.edu


generated by doc++