Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. public class Server {
  2.    
  3.     private final int port;
  4.     private final ServerSocket serverSocket;
  5.     private Socket clientSocket;
  6.     private DataInputStream in;
  7.     private Shape shape;
  8.     private static final int COUNT_OF_ARGUMENTS =3;
  9.    
  10.     public Server(int port, Shape shape) throws IOException
  11.     {
  12.         this.port=port;
  13.         this.shape=shape;
  14.         serverSocket = new ServerSocket(port);
  15.     }
  16.    
  17.     public void StartListening() throws IOException
  18.     {
  19.        
  20.         double[] inputData = new double[COUNT_OF_ARGUMENTS];
  21.        
  22.         while(true!=false)
  23.         {
  24.             clientSocket = serverSocket.accept();
  25.             in = new DataInputStream(clientSocket.getInputStream());
  26.             for(int i=0;i<3;i++)
  27.             inputData[i]=in.readDouble();
  28.             Client client = new Client(clientSocket,inputData, shape);
  29.             client.run();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement