Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 11:19, 23 November 2007.

TSS000265 - Specifying routing settings to a specific socket connection

From Forum Nokia Wiki


ID TSS000265 Creation date July 7, 2005, updated November 23, 2007
Platform S60 2nd Edition,
S60 2nd Edition, FP1, FP2, and FP3
S60 3rd Edition
Series 80 2nd Edition
Nokia 7710
Devices  
Category Symbian C++ Subcategory Networking

Overview

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.

Description

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.

Solution

// Connect to the socket server
RSocketServ socketServ;
socketServ.Connect();
// Open a channel<br>RSocket sock;
User::LeaveIfError(sock.Open(socketServ, 
                         KAfInet,
                         KSockStream,
                         KProtocolInetTcp));
// Packaging the variable and setting the values
TPckgBuf<TSoInetRouteInfo> info;
info().iDstAddr.SetAddress(iDestAddr);
info().iNetMask.SetAddress(INET_ADDR(255,255,255,0));
info().iGateway.SetAddress(INET_ADDR(127,0,0,1));
info().iIfAddr.SetAddress(INET_ADDR(0,0,0,0));
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,
                   KSolInetRtCtrl,
                   info);
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.

 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZKnowledgeBaseContentQ
     qfnZtypeQUqfnTypeZTechnicalSolutionQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX