Msrp/MsrpServer/src/CMSRPConnector.cpp
branchMSRP_FrameWork
changeset 58 cdb720e67852
parent 25 505ad3f0ce5c
equal deleted inserted replaced
25:505ad3f0ce5c 58:cdb720e67852
    68 // 2nd phase constructor
    68 // 2nd phase constructor
    69 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    70 //
    70 //
    71 void CMSRPConnector::ConstructL()
    71 void CMSRPConnector::ConstructL()
    72     {
    72     {
       
    73     MSRPLOG( "-> CMSRPConnector::ConstructL" )
    73     //iState = ENotConnected;
    74     //iState = ENotConnected;
    74     iTimer = CMSRPTimeOutTimer::NewL( *this );
    75     iTimer = CMSRPTimeOutTimer::NewL( *this );
    75     //create socket
    76     //create socket
    76 
    77 
    77     iSocket = new (ELeave) RSocket();   
    78     iSocket = new (ELeave) RSocket();
    78     User::LeaveIfError( iSocket->Open(
    79     RSocketServ& socketServ = iConnMngr.SocketServer();
    79             iConnMngr.SocketServer(), KAfInet, KSockStream, KProtocolInetTcp, iConnMngr.SocketServerConn()));
    80     RConnection& connection = iConnMngr.SocketServerConn();
    80     User::LeaveIfError( iSocket->SetOpt( KSoReuseAddr, KSolInetIp, ETrue ) );
    81     TInt error = iSocket->Open( socketServ, KAfInet, KSockStream, KProtocolInetTcp, connection );
    81     iSocket->SetLocalPort(KMsrpPort);
    82     MSRPLOG2( "CMSRPConnector::ConstructL = open error = %d", error )
       
    83     if ( error )
       
    84         {
       
    85         // if open fails, let's try to restart connection
       
    86         MSRPLOG( "CMSRPConnector::ConstructL restarting interface" )
       
    87         iConnMngr.ReStartInterface();
       
    88         error = iSocket->Open( socketServ, KAfInet, KSockStream, KProtocolInetTcp, connection );
       
    89         }
       
    90     User::LeaveIfError( error );
       
    91     error = iSocket->SetOpt( KSoReuseAddr, KSolInetIp, ETrue );
       
    92     MSRPLOG2( "CMSRPConnector::ConstructL = opt error = %d", error )
       
    93     User::LeaveIfError( error );
       
    94     iSocket->SetLocalPort( KMsrpPort );
       
    95     MSRPLOG( "<- CMSRPConnector::ConstructL" )
    82     }
    96     }
    83 
    97 
    84 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    85 // CMSRPConnector::DoCancel
    99 // CMSRPConnector::DoCancel
    86 // Cancels outstanding request.
   100 // Cancels outstanding request.