You are on page 1of 1

import java.io.

IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerProgram1 {

public static void main(String args[]) throws IOException {

ServerSocket serverSocket = null;


int port =7771;
System.out.println("Server is waiting to accept user...");
int clientNumber = 1;

// Try to open a server socket on port 7777


// Note that we can't choose a port less than 1023 if we are not
// privileged users (root)

try {
//TODO Cr�er une serverSocket sur le port 7771
serverSocket = new ServerSocket(7771);
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}

try {
while (true) {
// Accept client connection request
// Get new Socket at Server.

Socket socket = serverSocket.accept();


//TODO Cr�er le thread responsable de gestion du client
new ServiceThread1(socket,clientNumber++).start();
}
} finally {
serverSocket.close();
}

public static void log(String message) {


System.out.println(message);
}
}

You might also like