Namespaces
Variants
Actions

Monitoring the Internet connection using Symbian C++

Jump to: navigation, search
Article Metadata

Article
Created: User:Technical writer 1 (30 May 2008)
Last edited: hamishwillee (15 Jun 2012)

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 15 June 2012, at 04:18.
97 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved