×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    40

    get ip address of a gprs connection

    Please I need to know how to retrieve the ip address of a gprs connection, can anyone help me?

    Thanks in advance

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    You must have an open connection and then you can write for example something like this:
    Code:
    TNameEntry Result;
    TRequestStatus status;
    TInetAddr inetAddr;
    RSocketServ sockServer;
    RHostResolver Resolver;
    
    // connect to socket server
    sockServer.Connect();
    
    // open a connection using for example Resolver. It can be done even by some other way
    Resolver.Open(sockServer,KAfInet, KProtocolInetUdp);
    
    // we need to send some data out
    Resolver.GetByName(_L("www.something.com"),Result, status);
    User::WaitForRequest(status);
    
    // here we get the address
    inetAddr.SetAddress(TInetAddr::Cast(Result().inetAddr).Address());
    Resolver.Close();	
    sockServer.Close();
    
    // and save it into buffer
    TBuf<16> ipaddress;
    inetAddr.Output(ipaddress);
    This code is quite dirty as we are sending some "rogue" packets into the network but it is simple and working solution..:-)

Posting Permissions

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