I'm having trouble with the "DailyAdviceClient" example in Head First chapter 15.
I've typed in the example as shown below:
When I run this I get the following exception:
java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Metho at java.net.PlainSocketImpl.doConnect(PlainSocketImpl. at java.net.PlainSocketImpl.connectToAddress(PlainSock at java.net.PlainSocketImpl.connect(PlainSocketImpl.ja at java.net.SocksSocketImpl.connect(SocksSocketImpl.ja at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.<init>(Socket.java:366) at java.net.Socket.<init>(Socket.java:180) at DailyAdviceClient.go(DailyAdviceClient.java:9) at DailyAdviceClient.main(DailyAdviceClient.java:26)
Obviously my socket connection has been refused.
Why is this?
Have I coded this incorrectly?
Is this server no longer valid? - after all the book was written a few years back.
I've had a quick Google and a search on JavaRanch and found no relevant references. I'd appreciate any inputs.
The above code for the client program seems to have no problem. Do you have a server program running before you execute the client? And is the server listening on the same port where the client is connecting to?
Hope this helps [ August 22, 2008: Message edited by: Amit Ghorpade ]
I had just typed in the code from the book assuming it was connecting to some server or other. Of course "127.0.0.1" is local host, so no I don't have any server program running! What a twit I am.
In the preceding text of the book they use "188.8.131.52" so I tried that and it just times out. So either this was just an example that they didn't expect anyone to run, i.e. this "Advice Guy" service doesn't exist or it now no longer exists.
Thanks for your help.
Joined: Jul 14, 2008
I have just read a bit further through the book and they've gone through the server code that's needed to make this work a few pages later!
I guess I was too keen to get it coded and should have read the next few pages before getting going, what a larf ......