Chapter 14. Building roll your own clients 279
14.4 Complete pseudocode samples
In this section, we provide you complete pseudocode for several useful execution flows. In
14.5, “Detailed code examples” on page 282, we provide two implementations of these
programming models in the C and Java programming languages.
14.4.1 Commit mode 1 send-receive programming
In this sample, we assume that you are interested in writing a program to send one
transaction to an IMS system using IMS Connect, under the commit mode 1
(send-then-commit) protocol, acknowledging the response (synchronization level confirm),
and using a transaction socket.
This program model corresponds to the simplified example presented at the beginning of the
chapter. Example 14-1 shows the pseudocode to implement this model.
Example 14-1 Pseudocode for a commit mode 1, sync level confirm, transactional socket
PROGRAM send_receive_cm1(host, port, datastore, transaction_data)
socket := open_socket(host, port) 1.
IRM := build_irm(commit_mode=1, synch_level=CONFIRM, data_store=datastore, 2.
type=SEND_RECEIVE, transaction=transaction_data);
send(socket,IRM);
response := receive(socket); 3.
if (response is a RSM) 4.
print_error_details(response.RSM_data);
else
if (response contains a CSM)
process_response(response.segment_data);
if (response.ack_needed) 5.
IRM := build_irm(commit_mode=1, synch_level=CONFIRM, data_store=datastore,
type=ACK, transaction=NULL);
send(socket,IRM);
response := receive(socket); 6.
if (response.RSM IS NOT “deallocate commit”)
print_error_details(response.RSM_data);
<prepare abnormal termination>
else
<everything OK, prepare normal termination>
endif
endif
else
print_error_details(response.RSM_data);
<prepare abnormal termination>
endif
endif
close(socket); 7.
END send_receive_cm1;
The following numbers correspond to the numbers in Example 14-1:
1. To communicate to IMS Connect, we need to create and open a TCP socket bound to the
host and port where IMS Connect is listening.
2. Next, we prepare and send the input message structure, according to 14.2.1, “The IMS
Connect input message” on page 268.
3. Now, we read the response from the socket. IMS Connect waits for OTMA up to the
maximum time we specified in the IRM_TIMER field of the IRM prefix. We can also use
the TCP/IP timeout features to avoid blocking too much time.

Get IMS Connectivity in an On Demand Environment: A Practical Guide to IMS Connectivity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.