5.3 Guidelines for Writing Servers

Because the communication details are handled by the Oracle Tuxedo system main() routine, you can concentrate on the application service logic rather than communication implementation. For compatibility with the system-supplied main(), however, application services must adhere to certain conventions. These conventions are referred to, collectively, as the service template for coding service routines. They are summarized in the following list. Refer to the tpservice(3c) reference page in the Oracle Tuxedo ATMI C Function Reference for more information on these conventions.

  • A request/response service can receive only one request at a time and can send only one reply.
  • When processing a request, a request/response service works only on that request. It can accept another only after it has either sent a reply to the requester or forwarded the request to another service for additional processing.
  • Service routines must terminate by calling either the tpreturn() or tpforward() function. These functions behave similarly to the C language return statement except that after they finish executing, control returns to the Oracle Tuxedo system’s main() instead of the calling function.
  • When communicating with another server via tpacall(), the initiating service must either wait for all outstanding replies or invalidate them with tpcancel() before calling tpreturn() or tpforward().
  • Service routines are invoked with one argument, svcinfo , which is a pointer to a service information structure (TPSVCINFO).