ACSE/Presentation and ROSE Interface Programmer's Guide

60 Chapter 4
Programming Guide
5. Managing Multiple Connections
Connection Retry
When there is a resource shortage, ap_snd() may return AP_AGAIN. The
application should re-send the same primitive as outlined in the ap_snd()
manpage.
NOTE In the case of a connection request (A_ASSOC_REQ), if a resource
shortage occurs in the OTS stack, a reject may be received as a
A_PABORT_IND or A_ABORT_IND.
A_PABORT_IND indicates a shortage of memory in the OTS stack while
trying to establish a connection. This is caused by the dynamic memory
allocation scheme in the stack. A_ABORT_IND may occur if there is a
memory shortage on the remote side of the connection request.
To handle this situation, an application can implement a connection
retry mechanism to re-send the request again. Keep in mind that this
type of resource shortage problem should be temporary. To avoid waiting
indefinitely, set a counter to keep track of the number of retries.
Resource Constraints
Each connection will take up some resources of the system. These
resources may include file descriptors and memory space. Since A/P uses
ap_open() to create a communication endpoint and each endpoint
corresponds to a file descriptor, there is a limited number of file
descriptors that can be opened per process. For memory usage, when it is
initially started, each A/P instance will take up about 540 bytes. This
memory is consumed by the storage of the A/P environment attributes
and buffer space for the A/P library itself.
The actual size of memory used per connection depends on the values of
its environment attributes. For example, AP_BIND_PADDR may have a
longer or shorter address. In addition to the A/P library memory usage,
connections use some space within the OTS stack at each layer including
the presentation, session, and transport layers.
For an application with a large number of connections, you need to be
aware of the following system behavior and limitations:
System maximums
Process maximums
Other application interactions