Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2004

Tip: Looking for answers? Try searching our database.

a simple question about sockets

Thread view: 
Jerem38 - 05 May 2004 16:11 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.