class AppServer

Application server class

Inheritance:


Public Methods

AppServer(const char* Name=0, long ofl=o_none)
Construct a server.
~AppServer(void)
destroy the server.
void addHandler(MsgHeader::MsgType type, MsgHandler* handle)
Specify a message handler.
error_t close(void)
Close the server socket.
error_t handleMessage(void)
Read a message and handle it.
error_t open(long flags)
Open the server socket.
error_t receive(MsgHeader& hdr, void* data, size_t length, double timeout)
Receive a message.
error_t receive(MsgHeader& hdr, void* data, size_t length)
Receive a message.
error_t reply(const MsgHeader& to, const Message& data)
Reply to a client request.
error_t reply(const MsgHeader& to, const MsgHeader& rhdr, const void* data)
Reply to a client request.
error_t send(const MsgHeader& hdr, const Message& msg)
Send a message to a peer.
error_t send(const MsgHeader& hdr, const void* data)
Send a message to a peer.
bool waitMsg(wtime_t time)
Wait for a message to arrive.
bool isOpen(void) const
Test is socket is oopen.
wtime_t getTimeOut(void) const
Get the default wait time.
index_t getDebug(void) const
Debug level.
error_t register_name(const char* server, NameProcs type=p_Any)
Register the server name.
void setDebug(index_t 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_t 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)
Construct an message server and optionally register it with the local name server.
Parameters:
Name - Server name.
ofl - Open flags.

~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 sppropriate handler.
Parameters:
type - Message type to be handled.
handle - Message handler pointer.

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

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

error_t 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_t receive(MsgHeader& hdr, void* data, size_t 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_t receive(MsgHeader& hdr, void* data, size_t 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_t 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_t 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_t 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_t 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_t 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 not received.
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.

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

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

error_t 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_t 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_t 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.


Direct child classes:
MonServer
Author:
John Zweizig.
Version:
1.1; Modified April 21, 2000

alphabetic index hierarchy of classes


generated by doc++