MWSERVICE
Section: MidWay Programmer's Manual (3C)
Updated: DATE
Index
Return to Main Contents
NAME
- MidWay service routines
SYNOPSIS
#include <MidWay.h>
int functionname(mwsvcinfo * msi);
DESCRIPTION
This is the prototype for writing service routines in C.
A function must be registered as a MidWay service routine with
mwprovide()
where you give what name it should be announced with in the MidWay
instance. You can either do mwprovide directly or by compile the C
function into a shared library and use either
mwserver()
or give the shared library as an executable in the config file for
mwd(). (see mwd.conf(4)).
The input parameters to the routine is given by the struct mwsvcinfo:
struct _mwsvcinfo {
int handle;
CLIENTID cltid;
SERVERID srvid;
char * data;
int datalen;
int flags;
char service[MWMAXSVCNAME];
time_t deadline; /* deadline here is pretty much a timeval struct. */
int udeadline; /* see gettimeofday(); */
};
Struct Description
- handle
-
The handle returned by
mwacall().
This is for info only.
- cltid
-
The Client ID of the instance member that performed the
mwacall().
- srvid
-
If this call has been forwarded by another server thru the
mwforward()
call the id of the
last
server who did this is recorded here, UNASSIGNED (-1) otherwise.
- data / datalen
-
The input data to the service function. datalen is never 0 even if 0
in the
mw(a)call().
- flags
-
The flags given in the client process to
mw(a)call().
- service
-
The service name used in the
mw(a)call() or mwforward()
call. This is needed in case you have registered the same C functions
as service routines for multiple services.
- deadline / udeadline
-
If the client had set a deadline with
mwbegin()
it is given here. You can compare with
gettimeofday()
is find out how much time remains. If you know that your routine will
not complete in time you might as well return with ETIME
immediately. This is optional, and is probably only needed in near
realtime applications.
If your service routine need to return data or an application level
return code you need to call
mwreply()
to do so. The C return shall only return success (0) or failure (!0)
of the service call.
WARNINGS
EXAMPLES
int MYSERVICE (mwsvcinfo *msi)
{
printf ("got a call from client %d, flags %#X, data= msi->cltid, msi->flags, msi->data, msi->datalen);
mwreply ("Hello Client!", 0, MWSUCCESS, 0, 0);
return ;
};
BUGS
SEE ALSO
MidWay(7), mwreply(3C), mwacall(3C)
STANDARDS
NONE
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- Struct Description
-
- WARNINGS
-
- EXAMPLES
-
- BUGS
-
- SEE ALSO
-
- STANDARDS
-
This document was created by
man2html,
using the manual pages.
Time: 11:18:50 GMT, October 24, 2000