This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes URL Posting and NSLOOKUP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "URL Posting and NSLOOKUP" Watch "URL Posting and NSLOOKUP" New topic
Author

URL Posting and NSLOOKUP

Rajkumar Sathiya
Greenhorn

Joined: Dec 15, 2009
Posts: 8
[color=#444444]
[size=12]
My application is posting a xml string to external Server(i refer it as cleint hereafter).
We are doing URL posting not IP based, means never bother about which IP the URL points to.
Often we are getting Connection Timed Out Exception
When we informed this to the support team in client, they asked us to switch over to other IP
I don't know how to implement this, since we always provide the domain name while opening a connection.
Below is the code which I use.

How it is possible to change the IP, when am using domain name to create a connection?

I used nslookup from command prompt, it sure provides 2 IP's for the same domain.
Kindly help me. Thanks.
[/size]
[/color]
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

Rajkumar Sathiya wrote:
How it is possible to change the IP, when am using domain name to create a connection?


Just replace the domain name with the ip in the url.

You your client is using redundancy, it is possible that there are two ip's to the same domain.
In that case you can use any one ip.


- Chinna
Rajkumar Sathiya
Greenhorn

Joined: Dec 15, 2009
Posts: 8
Thanks for your response.
But, if I use IP instead of domain name, will client authentication work?
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

It should work.. because.. your HostNameVerifier is always returning true.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
I used nslookup from command prompt, it sure provides 2 IP's for the same domain.

This sounds odd. While there can be multiple host names that resolve to the same IP address, any particular host name can not resolve to more than one IP address (the DNS "A" record). Are you sure that you have the correct host name?

You could also use a library like DNSJava to look up all records for a given host name, and decide how to proceed based on that information.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: URL Posting and NSLOOKUP
 
Similar Threads
Received fatal alert: handshake_failure
How to attach a certificate to a socket and send a https POST request?
Problem with Intial Context with t3s protocal
Question about HttpsURLConnection
Http Post