8.3.1 Broadcasting Messages by Name

The tpbroadcast(3c) function allows a message to be sent to registered clients of the application. It can be called by a service or another client. Registered clients are those that have successfully made a call to tpinit() and have not yet made a call to tpterm().

Use the following signature to call the tpbroadcast() function:

int
tpbroadcast(char *lmid, char *usrname, char *cltname, char *data, long len, long 
flags)

The following table describes the arguments to the tpbroadcast() function.

Table 8-3 tpbroadcast( ) Function Arguments

Argument Description
lmid Pointer to the logical machine identifier for the client. A value of NULL acts as a wildcard, so that a message can be directed to groups of clients.
usrname Pointer to the username of the client process, if one exists. A value of NULL acts as a wildcard, so that a message can be directed to groups of clients.
cltname Pointer to the client name of the client process, if one exists. A value of NULL acts as a wildcard, so that a message can be directed to groups of clients.
data Pointer to the content of a message.
len Size of the message buffer. If data points to a self-defining buffer type, for example, FML, then len can be set to 0.
flags Flag options. Refer to tpbroadcast(3c) in the Oracle Tuxedo ATMI C Function Reference for information on available flags.

The following listing illustrates a call to tpbroadcast() for which all clients are targeted. The message to be sent is contained in a STRING buffer.

Listing Using tpbroadcast( )

char *strbuf;

if ((strbuf = tpalloc("STRING", NULL, 0)) == NULL) {
         error routine   
         }  
(void) strcpy(strbuf, "hello, world"); 

if (tpbroadcast(NULL, NULL, NULL, strbuf, 0, TPSIGRSTRT) == -1)
              error routine