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.

Specifying routing settings to a specific socket 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
Tested with
Devices(s): Nokia 7710
Platform(s): S60 2nd Edition,
S60 2nd Edition, FP1, FP2, and FP3
S60 3rd Edition
Series 80 2nd Edition
Created: User:Technical writer 1 (July 7, 2005, updated November 23, 2007)
Last edited: lpvalente (11 Jun 2014)


In a controlled network environment you may often find yourself having to set specific routing options to your socket connection. This tip details how this can be done with Symbian sockets.


Specific settings can be set through the TSoInetRouteInfo type, which encapsulates a set of routing-specific variables into one package (i.e., gateway, subnet mask, etc). The object must then be packaged in to a TPckgBuf type object so it can be passed to the SetOpt() function.

You also need to use the INET_ADDR macro that can be found in the in_sock.h header. This macro forms a 32-bit integer from a normal dotted-decimal IP address.


// Connect to the socket server
RSocketServ socketServ;
// Open a channel<br>RSocket sock;
// Packaging the variable and setting the values
TPckgBuf<TSoInetRouteInfo> info;
info().iMetric = 0;<br>// KSolInetRtCtrl indicates we are manually making
// changes to the routing table, that way SetOpt()
// accepts the info parameter.
TInt ret = sock.SetOpt(KSoInetAddRoute,
if(ret == KerrNone)
// Start using the socket

S60 3rd Edition

This solution applies to S60 3rd Edition as well. However, note that the application requires NetworkControl capability when using RSocket::SetOpt() with KSoInetAddRoute option.

This page was last modified on 11 June 2014, at 17:15.
26 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.