Acknowledging Messages


Acknowledging messages with GMD is also very easy. TipcMsgDestroy automatically calls TipcMsgAck to acknowledge the message for GMD. TipcMsgAck can also be called manually to acknowledge a message. For example:

if (!TipcMsgAck(msg)) { 
  /* error */ 
} 

TipcMsgAck constructs a GMD_ACK message containing the sequence number of the message to be acknowledged and sends the GMD_ACK message through the connection that the message to be acknowledged was received on. TipcMsgAck knows which connection to use through an internal message property containing the connection the message was received on.

You can disable the automatic acknowledgement of GMD messages with the Ipc_Gmd_Auto_Ack option. When automatic acknowledgment is disabled, it becomes the user’s responsibility to acknowledge receipt of the GMD message by calling TipcMsgAck.

Waiting for Completion of GMD

GMD senders must read messages occasionally to receive the acknowledgments. If a connection process both sends and receives messages at regular intervals, no extra actions are needed because the acknowledgments travel with the normal flow of messages. A short-running or sending-only process can accomplish this by calling TipcConnMainLoop or TipcConnRead before the program exits. A sending process can also check how many outgoing GMD messages are still pending with TipcConnGetGmdNumPending. This is useful for waiting until all acknowledgments arrive. For example:

TutOut("Read data until all acknowledgments come in.\n"); 
do { 
  if (!TipcConnMainLoop(conn, 1.0)) { 
    /* error */ 
    break; 
  } 
  if (!TipcConnGetGmdNumPending(conn, &num_pending)) { 
    /* error */ 
    break; 
  } 
} while (num_pending > 0); 

TIBCO SmartSockets™ User’s Guide
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com