HOWTO Do A Service Call ?

HOWTO "send" the data

A data-package is send in two different scenarios:
  1. on a client to call a service on the server
  2. on a server to answer a service call from the client

Sending data is an active task. Active mean, that the sending have to be triggered by the software-workflow.

Sending data is a sequence of commands to prepare a data-package and one command to send this package.

Important in the code from above is the last command MqSendEND because this is just one of three possibilities:
command description C C++ C# java python tcl perl VB.NET
MqSendEND Do a service-call without return data YES YES YES YES YES YES YES YES
MqSendEND_AND_WAIT Do a synchronous service-call with return data YES YES YES YES YES YES YES YES
MqSendEND_AND_CALLBACK Do a asynchronous service-call with return data YES YES YES YES YES YES YES YES

To send a data-package is one task, to send it to the right receiver is an other one. The right receiver is identified with the token parameter argument. This parameter have to be a 4 character string. You'll probably ask "why 4?" the answer is that this string have should be "human" readable and easy to "compare". As solution this string is mapped to a 4 byte integer used to find the proper key/value entry in the service-hash-table on the server. (in short: to search an integer is much faster as to search a string)

HOWTO "read" the data

A data-package is read in two different scenarios:
  1. on a server to serve an incoming service-call from the client
  2. on a client to process the return-data from a previous service-call
Reading data is a passive task in opposite to sending data which is an active task. Passive mean that the read is triggered by an incoming data-package and not by the software-workflow.

To setup a passive task two requirements are necessary:

  1. adding the service
  2. start the event-loop to listen on the incoming packages
To add a service the following code is necessary:

To start the event-loop and wait for 10 seconds for the return message the following code is used:

Finally to read the package-data the following code is necessary:

The libmsgque API is type-save and create an error if the requested type like MqReadI is not compatible with the next available type in the data-package.

libmsgque project on SF: Get libmsgque at SourceForge.net. Fast, secure and Free Open Source software downloads    Generated on Mon Nov 9 16:57:38 2009 by doxygen 1.5.8