Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Monitoring the Internet connection using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Article
Created: User:Technical writer 1 (30 May 2008)
Last edited: lpvalente (27 Jun 2014)

Contents

Use case

If an application is trying to connect to the Internet, it needs to be monitored, that is, which process is trying to connect and the related information.

Headers

CommDbConnPref.h
es_enum.h
es_sock.h
rconnmon.h

Libraries

commdb.lib
esock.lib

Capability

NetworkControl

Code snippet

The following code can be used to monitor on Internet connection and display the process UID and name which is trying to connect:

  RSocketServ socketServ;
RConnection connection;
TConnectionInfoBuf connInfo;
TUint count;
TConnEnumArgBuf enumArgBuf;
TConnMonClientEnum aClientEnum;
TInt err;
TConnGetClientInfoArgBuf clientInfoBuf;
socketServ.Connect();
connection.Open( socketServ );
 
// Enumerates currently active interfaces
if( connection.EnumerateConnections(count) == KErrNone )
{
for ( TUint j=1; j<=count; j++ )
{
enumArgBuf().iIndex = j;
if(connection.Control( KCOLConnection,
KCoEnumerateConnectionClients,
enumArgBuf ) == KErrNone )
{
for ( TUint i=1; i <= enumArgBuf().iCount; i++ )
{
clientInfoBuf().iIndex = i;
err = connection.Control( KCOLConnection,
KCoGetConnectionClientInfo,
clientInfoBuf );
if ( err != KErrNone )
{
continue;
}
 
TInt uid = clientInfoBuf().iClientInfo.iUid.iUid;
RProcess process;
process.Open(clientInfoBuf().iClientInfo.iProcessId );
process.Name();
TBuf<16> buf;
buf.AppendNum( uid, EHex );
CEikonEnv::InfoWinL( buf, process.Name() );
process.Close();
}
}
}
}
 
connection.Close();
socketServ.Close();
This page was last modified on 27 June 2014, at 21:32.
50 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×