Results 1 to 1 of 1
  1. #1
    DeNiS_M is offline Member
    Join Date
    Sep 2011
    Location
    Athens Greece
    Posts
    29
    Rep Power
    0

    Default Finger Protocol problem

    Hello guys.

    I'm writing a simple finger client.
    Here is the code:
    Java Code:
    /**
     * Project: SocketExamples
     * File: JFinger.java
     * Created on: 19 Sep 2011
     */
    package example1;
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.net.Socket;
    
    /**
     * @author denis
     */
    public class JFinger
    {
    	private static final int DEFAULT_PORT = 79;
    	private static String host;
    
    	
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args)
    	{
    		Socket connection = null;
    		try
    		{
    			host = args[0];
    			connection = new Socket(host, DEFAULT_PORT);
    			OutputStreamWriter out =
    				new OutputStreamWriter(connection.getOutputStream(), "8859_1");
    			out.write("finger "+host);
    			InputStreamReader in =
    				new InputStreamReader(connection.getInputStream());
    			int c = 0;
    			while ((c = in.read()) != -1)
    			{
    				System.out.println((char) c);
    			}
    			in.close();
    			out.close();
    		}
    		catch (IOException ioe)
    		{
    			System.out.println("Exception opening connection: "+ioe.getMessage());
                            ioe.printStackTrace();
    		}
    		catch (ArrayIndexOutOfBoundsException aiobe)
    		{
    			System.out.println(aiobe.getMessage());
    		}
    		finally
    		{
    			try
    			{
    				if (connection != null)
    					connection.close();
    			}
    			catch (IOException e)
    			{
    				System.out.println("Exception closing socket: "
    					+ e.getMessage());
    			}
    		}
    	}
    
    }
    The problem i suspect lies in the fact that i can't bind the connection object in port 79
    resulting in an IOException (line 47) although i run the program in super user mode.
    I used netstat to see if an other service listen on that port but no one would.

    I can't think what might be wrong so i would like your help to solve this issue.

    Thanks

    Here is the output of my tests.
    Java Code:
    /home/denis/Eclipse_Projects/SocketExamples/bin # java example1.JFinger "localhost"
    Exception opening connection: Connection refused
    java.net.ConnectException: Connection refused
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
    	at java.net.Socket.connect(Socket.java:546)
    	at java.net.Socket.connect(Socket.java:495)
    	at java.net.Socket.<init>(Socket.java:392)
    	at java.net.Socket.<init>(Socket.java:206)
    	at example1.JFinger.main(JFinger.java:34)
    
    /home/denis/Eclipse_Projects/SocketExamples/bin # java example1.JFinger "denis"
    Exception opening connection: Connection refused
    java.net.ConnectException: Connection refused
    	at java.net.PlainSocketImpl.socketConnect(Native Method)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:327)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:193)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
    	at java.net.Socket.connect(Socket.java:546)
    	at java.net.Socket.connect(Socket.java:495)
    	at java.net.Socket.<init>(Socket.java:392)
    	at java.net.Socket.<init>(Socket.java:206)
    	at example1.JFinger.main(JFinger.java:34)
    Last edited by DeNiS_M; 09-19-2011 at 09:15 PM.

Similar Threads

  1. How to access finger print scanner?
    By JunedAhmed in forum Networking
    Replies: 6
    Last Post: 01-28-2011, 12:43 PM
  2. Finger print scanning and verification
    By kirly in forum Advanced Java
    Replies: 4
    Last Post: 01-29-2010, 01:24 AM
  3. x modem protocol
    By jithan in forum New To Java
    Replies: 0
    Last Post: 08-21-2008, 10:43 AM
  4. New Protocol?
    By lada.r in forum Networking
    Replies: 0
    Last Post: 11-06-2007, 09:13 PM
  5. how to use SIP protocol
    By katie in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 10:22 PM

Posting Permissions

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