I have made an httpServer which is connected with the client with Socket client = socket.accept(). Is there a command in order to choose which port I want to use to send messages to the client??
Asked
Active
Viewed 48 times
2 Answers
0
Your server will use the port that you selected when you create your ServerSocket socket = ServerSocket(your port)

Kenn Huang
- 1
- 2
0
You want to have a fixed outbound port on the client? You can't do that.
See How is source port for HTTP determined? Is there ever collision in NAT?
Why do you want to do that?
An httpServer only responds on client requests. It cannot send data to the client without a request from the client. If you want to have bi-directional communication, you need websockets.
-
Thank you for answering me. I didn't understand correctly what the project I have to do asked for – Dimitris Manonegra Apr 24 '17 at 17:05