×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    118

    How to determine IP address for device in S602nd fp3

    Hi guys i want to determine IP address of handset so please tell me
    how to get that information in s60 2nd FP3

  2. #2
    Regular Contributor
    Join Date
    Mar 2008
    Location
    Bangalore, India
    Posts
    68

    Re: How to determine IP address for device in S602nd fp3

    TInetAddr aAddr;
    RSocket sock;
    TBuf8<20> aIP8;
    TBuf<20> aIP;
    User::LeaveIfError(sock.Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp));

    // Get the IAP id of the underlying interface of this RConnection
    //TUint32 iapId = 0;
    //User::LeaveIfError(conn.GetIntSetting(_L("IAP\\Id"), iapId));

    // Get IP information from the socket
    TSoInetInterfaceInfo ifInfo;
    TPckg<TSoInetInterfaceInfo> ifInfoPkg(ifInfo);
    TSoInetIfQuery ifQuery;
    TPckg<TSoInetIfQuery> ifQueryPkg(ifQuery);
    // To find out which interfaces are using our current IAP, we must
    // enumerate and go through all of them and make a query by name for each.
    User::LeaveIfError(sock.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl));

    while(sock.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, ifInfoPkg) == KErrNone) {

    ifQuery.iName = ifInfo.iName;
    TInt err = sock.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, ifQueryPkg);
    if( err == KErrNone && ifQuery.iZone[1] == g_iapId)
    { // IAP ID is index 1 of iZone
    // We have found an interface using the IAP we are interested in.
    //if( ifinfo.iAddress.Address() >0 )
    if (!ifInfo.iAddress.IsUnspecified() && !ifInfo.iAddress.IsLoopback() && !ifInfo.iAddress.IsLinkLocal())
    {

    // found a IPv4 address
    aAddr = ifInfo.iAddress;
    aAddr.ConvertToV4();
    aAddr.Output(aIP);

    aIP8.Copy(aIP);

    strncpy(out,(char*)aIP8.Ptr(),aIP8.Length());


    sock.Close();
    return err; // stop & return KErrNone
    }
    }
    else if( err !=KErrNone ) {
    sock.Close();
    return err; // return with error
    }
    } // while
    sock.Close();
    return KErrNotFound; // return with KErrNotFound


    Regards,
    Pramod Murthy
    "Nobody will believe in you unless you believe in yourself."

  3. #3
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    118

    Re: How to determine IP address for device in S602nd fp3

    Code:
    // Get the IAP id of the underlying interface of this RConnection
    	TUint32 iapId = 0;
    	iAppUi->ShowNoteL(_L("Inside GetIPAddress"));
    	User::LeaveIfError(iConnection.GetIntSetting(_L("IAP\\Id"), iapId));
    	// To find out which interfaces are using our current IAP, we must
    		// enumerate and go through all of them and make a query by name
    		// for each.
    		iAppUi->ShowNoteL(_L("Setting SetOpt"));
    		User::LeaveIfError(iSocket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl));
    		while(iSocket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, ifinfopkg) == KErrNone)
    		{
    			iAppUi->ShowNoteL(_L("Inside While"));
    			ifquery.iName = ifinfo.iName;
    			TBuf<20> ErrDesc;
    			ErrDesc.Copy(_L("Err : "));
    			TInt err = iSocket.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, ifquerypkg);
    			ErrDesc.AppendNum(err);			
    			iAppUi->ShowNoteL(ErrDesc);
    			//if(err == KErrNone && ifquery.iZone[1] == iapId) // IAP ID is index 1 of iZone
    			if(err == KErrNone && ifquery.iZone[1] == iapId) // IAP ID is index 1 of iZone
    			{
    				// We have found an interface using the IAP we are interested in.
    				if(ifinfo.iAddress.Address() > 0)
    				{
    					// found a IPv4 address	
    					aAddr = ifinfo.iAddress;
    					iAppUi->ShowNoteL(_L("Found IP"));
    					//iSocket.Close();
    					return err; // stop & return KErrNone
    				}
    			}
    			else if(err != KErrNone)
    			{
    				//iSocket.Close();
    				return err; // return with error
    			}
    		} // while
    Whats wrong with this code?
    I am calling this after establishing connection.
    it shows Inside GetIPAddress
    after that no message displayed
    Last edited by ltomuta; 2008-06-17 at 20:38. Reason: Use the [CODE] tags, they're free ;)

Similar Threads

  1. how to determine phone's IP address?
    By xchip in forum Python
    Replies: 12
    Last Post: 2008-04-20, 15:24
  2. console application not running in S602nd FP2
    By avibatbha in forum Symbian C++
    Replies: 6
    Last Post: 2008-01-31, 15:22
  3. How do I determine the IP address of my phone?
    By tote in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2006-09-15, 09:49
  4. Aphanumeric Address formats on MM1?
    By shtobias in forum General Messaging
    Replies: 0
    Last Post: 2003-09-09, 07:49
  5. Help! Help! My IP address is changing like crazy !!
    By jwynn_in_nh in forum Mobile Java General
    Replies: 0
    Last Post: 2003-07-22, 22:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •