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 ?
Christophe Vanfleteren - 05 May 2004 16:26 GMT
> The accept() function of the class ServerSocket create a new Socket and
> return it.
<snip code>
See answer in c.l.j.programmer

Signature
Kind regards,
Christophe Vanfleteren
Thomas Schodt - 05 May 2004 17:05 GMT
> public static int port = 15555;
> ServerSocket ecoute = new ServerSocket(port,5);
[quoted text clipped - 5 lines]
> sockets (the newone created and the ServerSocket) connected to the same
> port ? Is it possible ?
Investigate:
netstat -na