I have written a simple program that opens a connection to a whois port on the InterNIC server, sends the command line argument down the socket, and then prints the data that is returned. But i am getting a ConnectException saying connection timed out.
Below is the program
JCE: added code tags [ October 22, 2008: Message edited by: Joe Ess ]
What is the book title and version? Does it reference a web site we can see the errata on? The code should work, it's just that there doesn't seem to be any service listening on port 43. We can easily get your code to connect to port 80, which we know works because we can access the web site:
Thank you very much..! The code is working fine. I should've guessed it. I believe that port 80 is for HTTP. right? I found the program from the book "The Complete Reference - Java 2 [5th Edition]" By Patrick Naughton and Herbert Schildt. No. It does not refer any site where we can see the error data.
Once Again, Thank you for your help and suggestions.
Originally posted by Nitin Menon: I should've guessed it. I believe that port 80 is for HTTP. right?
Right. Note that I had to make a couple of changes to get the code to work with HTTP as opposed to the nameless protocol the original code used: The two carriage return and new lines at the end of str and the flush. Using a different protocol, FTP for example, would require changes as well.