J
Jerem38
The accept() function of the class ServerSocket create a new Socket and
return it.
public class ServeurEcouteur {
public static int port = 15555;
public static void main(String[] args) {
try {
ServerSocket ecoute = new ServerSocket(port,5);
while(true) {
Socket service;
service = ecoute.accept();
System.out.println(service.getLocalPort());
System.out.println(ecoute.getLocalPort());
new Thread (new ServeurConnection(service)).start();
}// end while
}//end try
catch (Exception e) {
System.out.println("erreur cote serveur ecouteur"+e);
}
}
I don't understand why the 2 println return the same value. Are the 2
sockets (the newone created and the ServerSocket) connected to the same
port ? Is it possible ?
return it.
public class ServeurEcouteur {
public static int port = 15555;
public static void main(String[] args) {
try {
ServerSocket ecoute = new ServerSocket(port,5);
while(true) {
Socket service;
service = ecoute.accept();
System.out.println(service.getLocalPort());
System.out.println(ecoute.getLocalPort());
new Thread (new ServeurConnection(service)).start();
}// end while
}//end try
catch (Exception e) {
System.out.println("erreur cote serveur ecouteur"+e);
}
}
I don't understand why the 2 println return the same value. Are the 2
sockets (the newone created and the ServerSocket) connected to the same
port ? Is it possible ?