servicediscoveryandcontrol/pnp/test/upnp/SocketHandler/inc/rsockethandler.h
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // @internalAll
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __RSOCKETHANDLER_H__
       
    19 #define __RSOCKETHANDLER_H__
       
    20 
       
    21 #include <es_sock.h>
       
    22 #include <comms-infras/eintsock.h>
       
    23 
       
    24 #include "sockhandlerdefs.h"
       
    25 
       
    26 using namespace SockHandler;
       
    27 
       
    28 class CSocketHandler;
       
    29 
       
    30 
       
    31 /** 
       
    32 A SocketHandler observer.
       
    33 
       
    34 Implementor of this class will be notified on completion of socket operations from a socket handler.
       
    35 
       
    36 @internalAll
       
    37 */
       
    38 class MSocketHandlerObserver
       
    39 	{
       
    40 public:
       
    41 	virtual void OpenComplete ( RInternalSocket& aSocket ) =0;
       
    42 	virtual void ConnectComplete () =0;
       
    43 	virtual void AcceptComplete ( RInternalSocket& aSocket ) =0;
       
    44 	virtual void SendComplete ( TInt aLength ) =0;
       
    45 	virtual void SendToComplete ( TInt aLength ) =0;
       
    46 	virtual void RecvComplete ( RMBufChain& aData ) =0;
       
    47 	virtual void RecvFromComplete ( RMBufChain& aData, const TSockAddr& aAddr ) =0;
       
    48 //	virtual void IoctlComplete () =0;
       
    49 	virtual void Error ( TOperation aOperation, TInt aError  ) =0;
       
    50 	};
       
    51 
       
    52 
       
    53 /**
       
    54 
       
    55 @internalAll
       
    56 */
       
    57 class RSocketHandler
       
    58 	{
       
    59 	public:
       
    60 
       
    61 	IMPORT_C RSocketHandler ( MSocketHandlerObserver& aObserver );
       
    62 	IMPORT_C void Attach ( RInternalSocket& aSocket );
       
    63 
       
    64 	IMPORT_C void Connect ( const TSockAddr& aAddr );
       
    65 	IMPORT_C void Accept ();
       
    66 	
       
    67 	IMPORT_C void Send ( RMBufChain& aData );
       
    68 	IMPORT_C void SendTo ( const RMBufChain& aData, TSockAddr& aAddr );
       
    69 	IMPORT_C void Recv ();
       
    70 	IMPORT_C void RecvFrom ();
       
    71 
       
    72 //	IMPORT_C void Send ( const TDesC8& aData );
       
    73 //	IMPORT_C void SendTo ( const TDesC8& aData, TSockAddr& aAddr );
       
    74 	
       
    75 //	IMPORT_C void Ioctl ( TUint aCommand, TDes8* aData = 0, TUint aLevel = KLevelUnspecified );
       
    76 
       
    77 //	IMPORT_C void Cancel ( TOperation aOperation );
       
    78 	IMPORT_C void CancelAll ();
       
    79 	
       
    80 	private:
       
    81 	CSocketHandler* FreeSocketHandler ( TOperation aOperation );
       
    82 	CSocketHandler* ActiveSocketHandler ( TOperation aOperation );
       
    83 	void ActivateSocketHandler ( TSocketHandlerParams& aParams );
       
    84 	
       
    85 	private:
       
    86 	RInternalSocket					iSocket;			// Socket to perform operations. Not owned.
       
    87 	MSocketHandlerObserver&			iObserver;			// Observer for socket operational success completion & error conditons
       
    88 	
       
    89 	RPointerArray < CSocketHandler > iSocketHandlers;	// Number of socket handlers
       
    90 	TUint32							iReserved [ 2 ];	// reserved
       
    91 	};
       
    92 
       
    93 #endif // __RSOCKETHANDLER_H__