Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UnknownHostException when trying to connect to localhost

 
Sue Cavanaugh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sue Cavanaugh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic