HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Working with the Transport Layer 301
Connection API
Sample Code
The following sample code demonstrates how to create an application
connection. The application becomes the connection owner and supplies the
connection with its event handlers. In this example, the application chooses to
register only on the RvSipTransportConnectionStateChangedEv() callback
function.
/*=========================================================================================*/
static RvStatus AppCreateAndInitConnection1(
IN RvSipTransportMgrHandle hTransportMgr,
OUT RvSipTransportConnectionHandle *phConn)
{
RvStatus rv;
RvSipTransportConnectionCfg connCfg;
RvSipTransportConnectionEvHandlers evHandlers;
/*Initializes the event handler structure.*/
memset(&evHandlers,0,sizeof(evHandlers));
evHandlers.pfnConnStateChangedEvHandler = AppConnStateChangedEv;
/*Creates a connection object and supplies the event handlers. In this sample, the
owner is set to NULL.*/
rv = RvSipTransportMgrCreateConnection(hTransportMgr, NULL, &evHandlers,
sizeof(evHandlers), phConn);
if(rv != RV_OK)
{
printf("Failed to create a connection object");
return rv;
}
/*Initializes the configuration structure. Setting the local address is optional.*/
memset(&connCfg,0,sizeof(RvSipTransportConnectionCfg));
connCfg.eTransportType = RVSIP_TRANSPORT_TCP;
connCfg.strDestIp = "172.20.1.1";
connCfg.destPort = 5060;
rv = RvSipTransportConnectionInit (*phConn,&connCfg,sizeof(connCfg));
if(rv != RV_OK)
{
printf("Failed to initialize the a connection object");
return rv;