Help! ClientServer coordinate translation system

Posted on 2003-03-31
Medium Priority
Last Modified: 2010-03-31
im currently doing a ClientServer coordinate translation system. this system has to be multi threaded too. i had briefly made a standalone program. how do i implement client server & multi threading to my this standalone system?? as in how do i send the program across when a user had successfully logged onto the server?
Question by:cedric_rhea
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 35

Expert Comment

ID: 8244281
 The best place to start is here: http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html

  which has a client-server tutorial and explains how you can turn it into a multiclient application. You can alos take a look here:


Expert Comment

ID: 8245401
Are you trying to send a program across, then you will need to use RMI - Remote method calls - javas rpc standard, or you could use JINI, all these are on the java website, a simple client server program that is threaded wont be able to call a method from the server.
LVL 30

Accepted Solution

Mayank S earned 280 total points
ID: 8260168
Ok, here is a small skeleton of a simple multithreaded (server-side of a) client-server program (assuming that strings are exchanged between the client and the server):

class MainServer
 public static void main ( String args[] )
   throws Exception
   ServerSocket ss = new ServerSocket ( <port-no> ) ;
   Socket s = ss.accept () ; // accept a new connection from a client
   new ServerThread ( s ) ; // start a new thread to serve this client dedicatedly

 } // end of main ()

} // class definition over

class ServerThread extends Thread
 Socket s ;
 BufferedReader br ;
 PrintWriter pw ;

 ServerThread ( Socket s )
     this.s = s ;  
     br = new BufferedReader ( new InputStreamReader ( s.getInputStream () ) ) ;
     pw = new PrintWriter ( s.getOutputStream (), true ) ;

   } // end of try block

   catch ( Exception e )
     System.out.println ( "\n Exception: " + e ) ;
     return ;

   } // end of catch block

   start () ; // new thread

 } // end of constructor ()

 public void run ()
     while ( true )
       // put entire functionality of the server here
       // use pw.println () to send data,
       // br.readLine () to read

       if ( <some-exiting-condition> ) // like, the client wishes to log out
         return ; // kill this thread

     } // end while
   } // end of try block

   catch ( Exception e ) // client gets disconnected by, say, a power-failure
     System.out.println ( "\n Exception: " + e ) ;
     return ; // kill this thread

   } // end of catch block

 } // end of run ()

} // class definition over

Hope that helps as a building block!


Expert Comment

ID: 9058359
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 30

Expert Comment

by:Mayank S
ID: 9371555
Recommendation: Accept mayankeagle's comment as answer.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question