Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

TCP and firewall  RSS feed

 
Cal Cheu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a server and client communicate by using TCP socket and they are separated by a firewall. Everytime the client sends back msg, it open a random port that cannot make it through the firewall. How can I restrict the port it opens? TIA
 
A. Wolf
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How come it opens a random port?
A socket can take the port number as an argument when you create it:
Socket s = new Socket(String host, int port);
there are plenty of other constructors for the Socket class found in the api.
are you telling it to create a random port? code would be nice to understand your situation better.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!