Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP Socket connection to a domain name

Status
Not open for further replies.

Griffyn

Programmer
Joined
Jul 11, 2002
Messages
1,077
Location
AU
Hi,

Just started learning java. I'm writing an Android app, and want to connect to a TCP server using a domain name, eg. myserver.mydomain.com

The code I'm using is:
Code:
Socket connfd = new Socket (InetAddress.getByName("myserver.mydomain.com").getHostAddress(), 3280);

This line causes the app to hang. If I remove the getHostAddress() bit, eg.
Code:
Socket connfd = new Socket (InetAddress.getByName("myserver.mydomain.com"), 3280);
Then it will timeout eventually, but never try the connection.

The TCP server app listening at the other end is a Delphi app I wrote with logging, and I can see that it's never receiving the connection request.

Help please?
 
It connects fine with a numerical IP.
 
Then my next check would be to print the result of InetAddress.getByName("myserver.mydomain.com").getHostAddress() to test it's resolving correctly.

Cheers,
Dian
 
Problem solved. Combination of the eclipse IDE not doing an inline resolve correctly, plus that I'd forgotten to poke a hole in the firewall - oops.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top