Send messages without including a header

You might want to use the high-speed connector to send messages from the z/TPF system to a remote platform that does not require a header or a length to describe the message.

For example, delimited messages like JSON or BSON are self-described documents that do not require a length to parse them. Many open source packages that consume these types of messages do not expect a header and it causes problems when a header is present.

With the high-speed connector, your applications can send messages from the z/TPF system to a remote platform without a header. The struct hsc_req high-speed connector structure in the tpf/connapi.h header file contains a flag byte called ihsc_flags. You can set the IHSC_NO_HEAD (X'80') flag to indicate that you want the high-speed connector to send the message without including the header in the transmission. Applications still prepend the header to the message like they normally do to send high-speed connector messages, but the z/TPF system adjusts the header and the length to send when this flag is set.

The header must be present for the high-speed connector to read responses from a remote system. Therefore, an error is returned if the IHSC_NO_HEAD flag is set and the application indicates that a response is expected. You can send messages without a high-speed connector header only when you send messages with the outbound model. When you use a request-reply model, you must include the header. Only the tpf_send_message API supports the outbound model where the application does not expect a response. The tpf_send_async_message API ignores the IHSC_NO_HEAD flag if it is set.

The following example shows an application that sends the message_req message of size req_size to a remote system without including the header. In this example, the IHSC_NO_HEAD flag is set.

  // Allocate storage for request_message and header
  char* request_buffer = (char *) malloc(req_size+HSC_HEADER_SIZE);

  //Setup the high speed connector header
  struct hsc_req* header = (struct hsc_req*) request_buffer;                    
  memset ((char*) header, 0, HSC_HEADER_SIZE);     //Initialize header area
  
  //Set the length, which does not include the 4-byte length field.  Also set the   
  //length of the header which is required when the IHSC_NO_HEAD is set.  
  header->length = (req_size + HSC_HEADER_SIZE) - sizeof (header->length);
  header->header_length = HSC_HEADER_SIZE;
  header->ihsc_flags |= IHSC_NO_HEAD;              //Set the flag to not send header

  // Bump past header and copy message                                
  char* data = request_buffer + HSC_HEADER_SIZE;
  memcpy (data, message_req, req_size)

  connector_parms.version       = HSC_VERSION_1;   //version 1                  
  connector_parms.endpointGroup = "nheadgrp";      //name of the endpoint group
  connector_parms.request       = request_buffer;  //buffer for the request message
  connector_parms.timeout       = 2;               //API timeout value - 2          
  connector_parms.response      = NULL;            //No response is 
  connector_parms.resp_len      = 0;               //  expected

  //Initialize the endpoint information 
  memset (endpoint_in, 0, sizeof(endpoint_in));                                 
  memset (endpoint_out, 0, sizeof(endpoint_out));                               
  connector_parms.endpoint_in   = endpoint_in;                                  
  connector_parms.endpoint_out  = endpoint_out;                                 

  //Issue the API to send the message 
  int rc = tpf_send_message(&connector_parms);

The header_length field in the hsc_req structure must be set to the length of the high-speed connector header. This field contains the length that you use to adjust pointers past the header and adjust the length.