upnp/upnpstack/ssdpserver/src/upnpudpserver.cpp
changeset 31 b51a6f4f15ba
parent 0 f5a58ecadc66
equal deleted inserted replaced
28:0060d1e93dc3 31:b51a6f4f15ba
     1 /** @file
     1 /** @file
     2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies  this distribution, and is available 
     6 * which accompanies  this distribution, and is available 
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    58 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    59 //
    59 //
    60 CUpnpUdpServer::CUpnpUdpServer( RSocketServ* aSocketServ,
    60 CUpnpUdpServer::CUpnpUdpServer( RSocketServ* aSocketServ,
    61                         MUpnpUdpServerObserver* aObserver,
    61                         MUpnpUdpServerObserver* aObserver,
    62                         TInt aListeningPort )
    62                         TInt aListeningPort )
    63     : CActive( EPriorityHigh ),
    63     : CActive( EPriorityStandard ),
    64       iMulticastFlags( 0 ),
    64       iMulticastFlags( 0 ),
    65       iMessagePtr( NULL, 0,0 ),
    65       iMessagePtr( NULL, 0,0 ),
    66       iIsStarted( EFalse )
    66       iIsStarted( EFalse ),
       
    67       iSocketDown( EFalse )
       
    68       
    67     {
    69     {
    68     LOGS( "SSDP *** CUpnpUdpServer::CUpnpUdpServer");
    70     LOGS( "SSDP *** CUpnpUdpServer::CUpnpUdpServer");
    69 
    71 
    70     CActiveScheduler::Add( this );
    72     CActiveScheduler::Add( this );
    71     iSocketServ = aSocketServ;
    73     iSocketServ = aSocketServ;
   368 // CUpnpUdpServer::RunL
   370 // CUpnpUdpServer::RunL
   369 // -----------------------------------------------------------------------------
   371 // -----------------------------------------------------------------------------
   370 //
   372 //
   371 void CUpnpUdpServer::RunL()
   373 void CUpnpUdpServer::RunL()
   372     {
   374     {
   373 
   375     TInt socketStatus = iStatus.Int();
   374     if ( iStatus.Int() != KErrNone )
   376     LOGS1( "SSDP *** CUpnpUdpServer::RunL - UDPServer error, error code: %d", socketStatus );
   375         {
   377     
   376         LOGS1( "SSDP *** CUpnpUdpServer::RunL - UDPServer error, error code: %d",
   378     if ( socketStatus != KErrNone )
   377             iStatus.Int() );
   379         {
   378 
   380         if ( ( socketStatus == KErrConnectionTerminated ) || ( socketStatus == KErrCannotFindProtocol )
   379         if ( iStatus.Int() != KErrCancel )
   381                || ( socketStatus == KErrDisconnected ) )
   380             {
   382             {
   381             ReceiveL();
   383             // When the WLAN newtork is lost or NCM cable is un-plugged, socket gets destroyed
       
   384             // and no send-receive operation can be performed over this socket.Hence simply
       
   385             // returning from RunL and setting the flag to true so that no further advertisement 
       
   386             // or search operations are carried over the dead socket.
       
   387             iSocketDown = ETrue;
       
   388             iLastSocketError = socketStatus;
       
   389             }
       
   390         else if ( socketStatus == KErrCancel )
       
   391             {
       
   392             // Send the pending request msgs 
       
   393             RestartOrContinueSendProcessingL();
   382             }
   394             }
   383         else
   395         else
   384             {
   396             {
   385             RestartOrContinueSendProcessingL();
   397             ReceiveL();;
   386             }
   398             }
   387         }
   399         }
   388     else
   400     else
   389         {
   401         {
   390         switch ( iState )
   402         switch ( iState )