aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes UnknownHostException when trying to connect to localhost Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "UnknownHostException when trying to connect to localhost" Watch "UnknownHostException when trying to connect to localhost" New topic
Author

UnknownHostException when trying to connect to localhost

Sue Cavanaugh
Greenhorn

Joined: Mar 12, 2004
Posts: 2
I'm a real greenhorn trying to run the DailyAdviceServer with DailyAdviceClient in two separate command windows on my computer. I started the server just fine in one cmd window and tried to run the client in another but got:

C:\sue\java_work\networking_and_threads>java DailyAdviceClient
java.net.UnknownHostException: 127,0,0,1
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at DailyAdviceClient.go(DailyAdviceClient.java:9)
at DailyAdviceClient.main(DailyAdviceClient.java:25)

Here's all the code (from Head First Java, 2nd Edition):






Thanks in advance for your help!
Sue
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

IPv4 addresses are usually represented in dot-decimal notation (four numbers, each ranging from 0 to 255, separated by dots, e.g. 208.77.188.166). Each part represents 8 bits of the address, and is therefore called an octet.


IP Address


[How To Ask Questions On JavaRanch]
Sue Cavanaugh
Greenhorn

Joined: Mar 12, 2004
Posts: 2
Thank you so much, Joe. I knew that's how IP addresses are formatted, but read the code
in the book wrong (need glasses) and didn't catch the inconsistency. I made the
change and my client is getting it's advice with no problem now!

Sue
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UnknownHostException when trying to connect to localhost