# examples/DataComms/Rconnection/rconnection.h

    00001 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
    00002 // All rights reserved.
    00003 // This component and the accompanying materials are made available
    00004 // under the terms of "Eclipse Public License v1.0"
    00005 // which accompanies this distribution, and is available
    00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    00007 //
    00008 // Initial Contributors:
    00009 // Nokia Corporation - initial contribution.
    00010 //
    00011 // Contributors:
    00012 //
    00013 // Description:
    00014 //
    00015
    00016 #ifndef RCONNECTION_H
    00017 #define RCONNECTION_H
    00018
    00019 #include <e32cons.h>
    00020 #include <in_sock.h>
    00021
    00022 #include <es_enum.h>
    00023 #include <commdbconnpref.h>
    00024
    00025 class CRConnection : public CBase
    00026         {
    00027 public:
    00028
    00029         //Constructor.
    00030         CRConnection(CConsoleBase* aConsole);
    00031
    00032         //Destructor.
    00033         ~CRConnection();
    00034
    00035         //Opens a session to the socket server and opens a connection that monitors for interface notification.
    00036         void StartESOCK();
    00037
    00038         //Demonstrates various RConnection API methods using default Commdb settings.
    00039         void DemoApiWithoutDbOverrideL();
    00040
    00041         //Demonstrates various RConnection API methods using non-default Commdb settings.
    00042         void DemoApiWithDbOverrideL();
    00043
    00044         //Starts a connection then attaches another connection to the same interface.
    00045         void AttachToExistingInterfaceL();
    00046
    00047         //Opens and starts a connection using non-default Commdb settings.
    00048         TInt ConnectWithDbOverrideL();
    00049
    00050         //Opens and starts a connection using default Commdb settings.
    00051         TInt ConnectWithoutDbOverrideL();
    00052
    00053         //Requests notification of the connection's progress.
    00054         void GetProgressNotification();
    00055
    00056         //Prints progress information to the console.
    00057         void DisplayProgressinfo(const TNifProgress& aProgress);
    00058
    00059         //Displays text describing the next phase of the example.
    00060         void DisplaySectionToDemo(const TDesC& aText);
    00061
    00062         //Prepares the socket for carrying out data transfer.
    00063         TInt PrepareSocket();
    00064
    00065         //Sends UDP packets over a socket.
    00066         TInt SendUdpData(TUint aPayloadSize);
    00067
    00068         //Receives UDP packets over a socket.
    00069         TInt RecvUdpData(TUint aPayloadSize);
    00070
    00071         //Calls SendUdpData() and RecvUdpData().
    00072         void DataSendAndReceive(TUint aPayloadSize);
    00073
    00074         //Gets the amount of data that has been transferred by the entire connection.
    00075         void DataTransferredRequest();
    00076
    00077         //Requests notification when a certain amount of data has been sent or received.
    00078         void DataTransferNotificationRequest();
    00079
    00080
    00081 private:
    00082         RConnection     iConnection;
    00083         RSocket                 iSocket;
    00084         RSocketServ             iSocketServ;
    00085         CConsoleBase*   iConsole;
    00086         TInetAddr               iDestAddr;
    00087         TInt                    iCurrentProgress;
    00088         RConnection     iMonitor;
    00089
    00090         };
    00091
    00092 #endif //RCONNECTION_H