Results 1 to 3 of 3
  1. #1
    rootnet47 is offline Member
    Join Date
    May 2011
    Posts
    14
    Rep Power
    0

    Default Whois Server does't replay anything

    Well I'm new to Java & it's networking concept and using Linux OS kernel 3.0.0-7 generic. I tried to compile following codes and get success but when I'm going to run it, it returns something weird which is not supposed to be the result.
    Java Code:
    import java.net.*;
    import java.io.*;
    
    class Whois
    {
    	public static void main(String args[]) throws Exception
    	{
    		int c;
    		Socket s = new Socket("internic.net", 43);
    		InputStream in = s.getInputStream();
    		OutputStream out = s.getOutputStream();
    		String str = (args.length == 0 ? "osborne.com" : args[0]) + "\n";
    		byte buf[] = str.getBytes();
    		out.write(buf);
    		while ((c = in.read()) != -1)
    		{
    			System.out.print((char) c);
    		}
    		s.close();
    	}
    }
    compile & run step :

    ricky@ricky-Rev-1-0:~/Desktop/java$ javac Whois.java
    ricky@ricky-Rev-1-0:~/Desktop/java$ java Whois
    Exception in thread "main" java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(Abstrac tPlainSocketImpl.java:337)
    at java.net.AbstractPlainSocketImpl.connectToAddress( AbstractPlainSocketImpl.java:198)
    at java.net.AbstractPlainSocketImpl.connect(AbstractP lainSocketImpl.java:180)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:391)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java.net.Socket.<init>(Socket.java:425)
    at java.net.Socket.<init>(Socket.java:208)
    at Whois.main(Whois.java:11)
    ************************************************** ******************************

    I've copied codes from the book which I'm following and where the result is given as

    Whois Server Version 1.3

    Domain Name: OSBORNE.COM
    Registrar: NETWORK SOLUTIONS, INC.
    Whois Server: whois.networksolutions.com
    Referral URL: Domain Names, Web Hosting and Online Marketing Services | Network Solutions
    Name Server: NS1.EPPG.COM
    Name Server: NS2.EPPG.COM

    Updated Date: 16-jan-2002
    >> Last update of whois database: Thu, 25 Apr 2002 05:05:52 EDT <<
    Could anyone help me to figure out the error and describe the region?
    Last edited by sunde887; 08-08-2011 at 09:39 PM. Reason: Added code tags, [code]...[/code]

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    786
    Rep Power
    5

    Default

    There is no service that is binded to port 43 on internic.net
    Try
    Socket s = new Socket("whois.internic.net", 43);
    instead of
    Socket s = new Socket("internic.net", 43);

    But that is exactly what is standing in the book or? (Java Tech - Chapter 13 : Networking Basics) :D

  3. #3
    rootnet47 is offline Member
    Join Date
    May 2011
    Posts
    14
    Rep Power
    0

    Default

    That right, it's just running and returning expected results. Thank you.

Similar Threads

  1. statment replay!!!
    By moamen in forum New To Java
    Replies: 4
    Last Post: 09-25-2009, 12:49 PM
  2. Ping a server when server is not in the localhost..
    By kshitiz in forum New To Java
    Replies: 1
    Last Post: 03-19-2009, 09:17 PM
  3. smtp server configuration with jboss server
    By vilas_patil in forum Java Servlet
    Replies: 0
    Last Post: 01-05-2009, 01:18 PM
  4. Replay Solutions Job Fair - Java & C++ Jobs
    By jackchang in forum Jobs Offered
    Replies: 0
    Last Post: 08-19-2008, 06:17 PM
  5. Does any file in an FTP server ends up in an HTTP server?
    By islamfunny in forum CLDC and MIDP
    Replies: 4
    Last Post: 08-15-2008, 04:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •