• Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket Programming - Doubts on Socket Port

 
Micheal John John
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just started learning on Socket programming and trying the below sample program in my local machine.

There should be 3 ports involoved in the below example program.





When the client trying to connect to the ServerSocket (4242), new random Socket port will be opened to serve the client and then ServerSocket again go to the wait state for the client request.
In the book it is mentioned "The Socket is on a different port than the ServerSocket, so that the ServerSocket can go back to waiting for other clients"

I want to print that port, the new random port which served the client request. I have just put lot of displays in both Client and server side socket object's as below..Am I missing something?









Server Output



Client Output

 
Claude Moore
Ranch Hand
Posts: 834
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can found a similar discussion on the topic just here at the Ranch:
Follow this link

I think you should play a bit with socket class' methods on both client and server side.. moreover, try to use
netstat to list all involved endpoints.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!