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:26, 23 November 2007.

How to convert TInetAddr to TBuf

From Forum Nokia Wiki

The Symbian Sockets RecvFrom function returns the IP Address in TInetAddr.To check how to get the Ip Address you can refer the following link LocalDeviceIpAddress

If you are aware of all the API's in TInetAddr then converting this to TBuf is not the problem, but if you are not aware then you can refer the below code .

Contents

PreRequities

TInetAddr address contains the IP Address obtained by using RecvFrom function of RSocket .

TInetAddr to TBuf

TInetAddr address;
TBuf <16> ipAddr;
 
TInetAddr :: Cast(address).Output(ipAddr);
// ipAddr  now contains  the IP Address.

Converting IpAddress to Char*

char* fromaddr;
//ipAddr = TBuf that we got from  above code 
for (i = 0; i < ipAddr.Length(); ++i )
{
  fromaddr[i] = char(ipAddr[i]);
}
fromaddr[i] = '\0';

For more information on Converting from Descriptor to Char Click on below link.

Converting Descriptor to Char and Char to Descriptor

Retrieving the Port and Family from TInetAddr

TUint port = address.Port();
TUint family = address.Family();


Related Links

LocalDeviceIpAddress

Related Discussions
Thread Thread Starter Forum Replies Last Post
grabbing hex value of a TChar? _nomad_ Symbian Networking & Messaging 5 2005-06-08 11:42
grabbing hex value of TChar _nomad_ General Symbian C++ 9 2005-06-09 08:04
socket problem yakoc General Symbian C++ 2 2005-05-10 06:22
DataBase Records retreival problem citrookie General Symbian C++ 3 2007-08-20 06:34
[Merged][Moved] How to copy unicode data in HBufC16* from a file amitnema General Symbian C++ 5 2008-03-05 11:03
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX