I have programmed a Router class which has two methods, receive and send.In receive method it receives the plain text from the server through port 2000.Its now all cool.In send method it sends the message to a client through the port 2001 but at the client i get an exceptionconnection refused:connectimport java.io.*; import java.util.*; import java.net.*; import java.sql.*; class Router { String str; public void receive() { try { while(true) { Socket so=new Socket("localhost",2000); BufferedReader br=new BufferedReader(new InputStreamReader(so.getInputStream())); str=br.readLine(); System.out.println("server has sent:"+str); so.close(); } } catch(IOException e) { e.printStackTrace(); } } public void send() { int i,index,min=100; int row=2; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection cn=DriverManager.getConnection("jdbc:odbc:DSN2"); Statement st=cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs=st.executeQuery("select * from Table1"); //rs.absolute(row); rs.next(); rs.next(); //System.out.println(rs.getInt(1)+"\t"+rs.getInt(2)+"\t"+rs.getInt(3)+"\t"+rs.getInt(4)+"\t"+rs.getInt(5)+"\t"+rs.getInt(6)); for( i=2;i<7;i++) { int value=rs.getInt(i); System.out.println("hello"); if(value<min) { index=i; min=value; } } } catch(Exception e) { e.printStackTrace(); } } } class Router1 { public static void main(String s[]) { Router obj=new Router(); obj.receive(); obj.send(); } }