diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-D24D5F17-462E-5424-99A7-9B16E9FEDC93.dita --- a/Symbian3/PDK/Source/GUID-D24D5F17-462E-5424-99A7-9B16E9FEDC93.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-D24D5F17-462E-5424-99A7-9B16E9FEDC93.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,139 +1,139 @@ - - - - - -Rconnection: -connection monitoring and management exampleThis example demonstrates the use of the RConnection API -to do connection monitoring and management. -
Purpose

The example demonstrates the following -features of the RConnection API:

    -
  • Opening and closing -a connection using RConnection::Open(RSocketServ& aSocketServer, -TUint aConnectionType = KConnectionTypeDefault) and RConnection::Close().

  • -
  • Starting a connection -that uses the default CommDb connection preferences, and another connection -that overrides them, using (respectively) RConnection::Start() and RConnection::Start(TConnPref& -aPref).

  • -
  • Getting the number of -connections, and retrieving information about one of them, using RConnection::EnumerateConnections(TUint& - aCount) and RConnection::GetConnectionInfo(TUint -aIndex, TDes8& aConnectionInfo).

  • -
  • Attaching a connection -to an existing interface, using RConnection::Attach(const TDesC8& -aConnectionInfo, TConnAttachType aAttachType).

  • -
  • Registering for notifications -when:

      -
    • a certain amount of -data has been sent, using RConnection::DataSentNotificationRequest(TUint -aThreshold, TPckg<TUint>& aUplinkVolume, TRequestStatus& -aStatus).

    • -
    • a certain amout of data -has been received, using RConnection::DataReceivedNotificationRequest(TUint -aThreshold, TPckg<TUint>& aDownlinkVolume, TRequestStatus& - aStatus).

    • -
    • interfaces go up and -down, using RConnection::AllInterfaceNotification(TDes8& aNotification, - TRequestStatus& aStatus).

    • -
    • the connection changes -state, using RConnection::ProgressNotification(TNifProgressBuf& -aProgress, TRequestStatus& aStatus, TUint aSelectedProgress -= KConnProgressDefault).

    • -
  • -
  • Obtaining the amount -of data transferred, using RConnection::DataTransferredRequest().

  • -
  • Obtaining the connection's -current state, using RConnection::Progress(TNifProgress& aProgress).

  • -
  • Stopping the connection, -using RConnection::Stop().

  • -
  • Closing the session -with the socket server using RSocketServ::Close().

  • -
-
Download

Click on the following link to download -the example: Rconnection.zip

Click: browse to view the example code.

-
Class Summary

The example demonstrates the following -classes:

RConnection

RSocket

RSocketServ

TCommDbConnPref

TConnectionInfoBuf

-
Design and implementation

The project implements -a single class called CRConnection, that has three principal -functions:

CRConnection::DemoApiWithoutDbOverrideL()

This -shows how to use RConnection to:

    -
  • start a connection and -associate it with an underlying interface, using default CommDb connection -preferences,

  • -
  • get notification when -the underlying interface goes up or down,

  • -
  • get notification about -the state of a connection as it becomes fully established,

  • -
  • transfer data over a -socket,

  • -
  • get the amount of data -transferred,

  • -
  • close the connection.

  • -

It also shows how to set up a socket to carry out data transfer.

CRConnection::DemoApiWithDbOverrideL()

This -is the same as DemoApiWithoutDbOverrideL() except that it:

    -
  • starts a connection -using non-default CommDb connection preferences,

  • -
  • requests notification -when a threshold amount of data has been transferred (instead of getting the -amount of data transferred).

  • -

CRConnection::AttachToExistingInterfaceL()

This shows -how to use RConnection to:

    -
  • open 2 connections and -start one of them (the other is not yet associated with an underlying interface),

  • -
  • get connection information -for the 1st connection and use this to attach the 2nd connection to the existing -interface,

  • -
  • get the state of the -attached connection,

  • -
  • close the connections.

  • -
-
Building and configuring

You can build the example -from the IDE or the command line.

If you use an IDE, import the bld.inf file -into your IDE, and use the build command of the IDE.

If you use the -command line, open a command prompt, and set the current directory to the -source code directory of the example. You can then build the example using -the SBSv1 build tools with the following commands:

bldmake -bldfiles

abld build

How to use bldmake and How to use abld describe -how to use the SBSv1 build tools.

Emulator:

Before -running the example, the emulator must be set up to use ethernet, as follows:

    -
  • Install WinPCap -4.0.2

  • -
  • Configure the emulator -using configchange.pl for -instance:

    configchange.pl --config ethernetWithCommDB --kernel -EKA2 --target winscw --variant udeb

  • -
  • Open ethernetced.xml in epoc32\winscw\c\ and -change the last 3 values in the LANBearer operation section -for "EKA2 Emulator Ethernet" in the LANBearerTable to:

    LastSocketActivityTimeout = 10 -LastSessionClosedTimeout = 10 -LastSocketClosedTimeout = 10

    i.e. change the three values from --1 to 10.

  • -
  • Save the file and then -run ced c:\ethernetced.xml from the eshell command prompt -in the emulator.

  • -
  • Download a UDP Echoserver. -An Echoserver is easily available on the internet.

  • -
  • Start the UDP Echoserver -and edit the rconnection.cpp file in the example code so -that the values for KDestAddr and KSockPort match -the values being used by the UDP Echoserver.

  • -
  • Build the application -using the commands described above and then run it.

  • -

Hardware:

    -
  • To run the example on -an H4 board, connect the H4 to the PC/network by serial cable. Copy ethernetced.xml to -a memory card and execute:

    ced e:\ethernetced.xml

    before -running the example.

  • -
-
Running the example

For the emulator, the example -builds an executable called rconnection.exe in the epoc32\release\winscw\<udeb -or urel>\ folder.

rconnection.exe is -a console-based application. The example takes input from the user and prints -to the console information about the various stages of the example.

+ + + + + +Rconnection: +connection monitoring and management exampleThis example demonstrates the use of the RConnection API +to do connection monitoring and management. +
Purpose

The example demonstrates the following +features of the RConnection API:

    +
  • Opening and closing +a connection using RConnection::Open(RSocketServ& aSocketServer, +TUint aConnectionType = KConnectionTypeDefault) and RConnection::Close().

  • +
  • Starting a connection +that uses the default CommDb connection preferences, and another connection +that overrides them, using (respectively) RConnection::Start() and RConnection::Start(TConnPref& +aPref).

  • +
  • Getting the number of +connections, and retrieving information about one of them, using RConnection::EnumerateConnections(TUint& + aCount) and RConnection::GetConnectionInfo(TUint +aIndex, TDes8& aConnectionInfo).

  • +
  • Attaching a connection +to an existing interface, using RConnection::Attach(const TDesC8& +aConnectionInfo, TConnAttachType aAttachType).

  • +
  • Registering for notifications +when:

      +
    • a certain amount of +data has been sent, using RConnection::DataSentNotificationRequest(TUint +aThreshold, TPckg<TUint>& aUplinkVolume, TRequestStatus& +aStatus).

    • +
    • a certain amout of data +has been received, using RConnection::DataReceivedNotificationRequest(TUint +aThreshold, TPckg<TUint>& aDownlinkVolume, TRequestStatus& + aStatus).

    • +
    • interfaces go up and +down, using RConnection::AllInterfaceNotification(TDes8& aNotification, + TRequestStatus& aStatus).

    • +
    • the connection changes +state, using RConnection::ProgressNotification(TNifProgressBuf& +aProgress, TRequestStatus& aStatus, TUint aSelectedProgress += KConnProgressDefault).

    • +
  • +
  • Obtaining the amount +of data transferred, using RConnection::DataTransferredRequest().

  • +
  • Obtaining the connection's +current state, using RConnection::Progress(TNifProgress& aProgress).

  • +
  • Stopping the connection, +using RConnection::Stop().

  • +
  • Closing the session +with the socket server using RSocketServ::Close().

  • +
+
Download

Click on the following link to download +the example: Rconnection.zip

Click: browse to view the example code.

+
Class Summary

The example demonstrates the following +classes:

RConnection

RSocket

RSocketServ

TCommDbConnPref

TConnectionInfoBuf

+
Design and implementation

The project implements +a single class called CRConnection, that has three principal +functions:

CRConnection::DemoApiWithoutDbOverrideL()

This +shows how to use RConnection to:

    +
  • start a connection and +associate it with an underlying interface, using default CommDb connection +preferences,

  • +
  • get notification when +the underlying interface goes up or down,

  • +
  • get notification about +the state of a connection as it becomes fully established,

  • +
  • transfer data over a +socket,

  • +
  • get the amount of data +transferred,

  • +
  • close the connection.

  • +

It also shows how to set up a socket to carry out data transfer.

CRConnection::DemoApiWithDbOverrideL()

This +is the same as DemoApiWithoutDbOverrideL() except that it:

    +
  • starts a connection +using non-default CommDb connection preferences,

  • +
  • requests notification +when a threshold amount of data has been transferred (instead of getting the +amount of data transferred).

  • +

CRConnection::AttachToExistingInterfaceL()

This shows +how to use RConnection to:

    +
  • open 2 connections and +start one of them (the other is not yet associated with an underlying interface),

  • +
  • get connection information +for the 1st connection and use this to attach the 2nd connection to the existing +interface,

  • +
  • get the state of the +attached connection,

  • +
  • close the connections.

  • +
+
Building and configuring

You can build the example +from the IDE or the command line.

If you use an IDE, import the bld.inf file +into your IDE, and use the build command of the IDE.

If you use the +command line, open a command prompt, and set the current directory to the +source code directory of the example. You can then build the example using +the SBSv1 build tools with the following commands:

bldmake +bldfiles

abld build

How to use bldmake and How to use abld describe +how to use the SBSv1 build tools.

Emulator:

Before +running the example, the emulator must be set up to use ethernet, as follows:

    +
  • Install WinPCap +4.0.2

  • +
  • Configure the emulator +using configchange.pl for +instance:

    configchange.pl --config ethernetWithCommDB --kernel +EKA2 --target winscw --variant udeb

  • +
  • Open ethernetced.xml in epoc32\winscw\c\ and +change the last 3 values in the LANBearer operation section +for "EKA2 Emulator Ethernet" in the LANBearerTable to:

    LastSocketActivityTimeout = 10 +LastSessionClosedTimeout = 10 +LastSocketClosedTimeout = 10

    i.e. change the three values from +-1 to 10.

  • +
  • Save the file and then +run ced c:\ethernetced.xml from the eshell command prompt +in the emulator.

  • +
  • Download a UDP Echoserver. +An Echoserver is easily available on the internet.

  • +
  • Start the UDP Echoserver +and edit the rconnection.cpp file in the example code so +that the values for KDestAddr and KSockPort match +the values being used by the UDP Echoserver.

  • +
  • Build the application +using the commands described above and then run it.

  • +

Hardware:

    +
  • To run the example on +an H4 board, connect the H4 to the PC/network by serial cable. Copy ethernetced.xml to +a memory card and execute:

    ced e:\ethernetced.xml

    before +running the example.

  • +
+
Running the example

For the emulator, the example +builds an executable called rconnection.exe in the epoc32\release\winscw\<udeb +or urel>\ folder.

rconnection.exe is +a console-based application. The example takes input from the user and prints +to the console information about the various stages of the example.

\ No newline at end of file