Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server;
- import java.io.*;
- import java.net.*;
- import client.ServerException;
- public class Server {
- public static final int PORT = 8080;
- public static void main(String[] args)throws IOException, ServerException{
- ServerSocket ss = new ServerSocket(PORT); // Il Server si mette in ascolto sulla porta 8080
- System.out.println("Server Avviato: " + ss);
- String choice = ""; // Operazione scelta sul client
- String table_name = "";
- float minSup = 0F;
- try{
- // Il server accetta la connessione
- Socket socket = ss.accept();
- // La connessione è avvenuta
- BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- PrintWriter out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
- try{
- System.out.println("Connessione accettata: " + socket);
- // Il Server legge ciò che il Client ha mandato
- while(true){
- choice = in.readLine();
- if(choice.equals("1")){
- out.println("Inserire il nome della tabella");
- table_name = choice;
- out.println("Inserire un valore di minSup compreso tra [0,1]");
- minSup = Float.valueOf(choice).floatValue();
- out.println("END");
- }else if(choice.equals("2")){
- // ....
- }
- if (choice.equals("END")) break;
- System.out.println("Ricevuto da Client: " + choice);
- }
- }finally{
- socket.close();
- }
- }
- finally {
- System.out.println("closing...");
- ss.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement