HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
286 HP-UX C SIP Stack Programmer’s Guide
Persistent Connection Handling
CONNECTION HASH To reuse open connections, client connections (connections opened by the
UAC) are inserted into a hash table. The connection hash key consists of the
following elements:
The connection transport (TCP or TLS)
The connection local address (IP and port)
The connection remote address (IP and port)
Whenever a SIP Stack object needs to send a message using a reliable transport
(TCP or TLS), it first queries the connection hash for existing opened
connections. If such a connection exists, it will be used for sending the message.
CONNECTION OWNER Each connection holds a list of owners. A connection owner is an element that
needs to use the connection and therefore asks to be one of the owners of the
connection. The connection notifies each of its owners about connection events.
If, for example, a transaction wishes to send a message using TCP transport
from address X to address Y, the transaction first queries the connection hash
for an existing suitable connection. If such a connection exists, the transaction
will attach itself to the connection and will become one of the connection
owners. The transaction can then use the connection for sending messages.
When the transaction no longer wishes to use this connection, it should detach
from the connection. After detaching from the connection, the transaction is no
longer allowed to use the connection and it will not be informed of connection
events. In the case where there is no suitable connection in the hash, a new
connection will be constructed. This new connection will be inserted into the
hash and other elements will be able to use it as well.
Note An element must not use a connection unless this element is a connection
owner.
CONNECTION
TERMINATION RULE
A basic rule of the persistent connection feature is that a connection will not
terminate as long as it has owners. A SIP Stack element that uses a connection
never specifically terminates it. An element that is no longer using a connection
needs to detach from the connection, by removing itself from the connection
Owners List. The connection will disconnect automatically when the Owners
List is empty.