Question

With regards to the problem Bart is having in NAT router blocking JMS messages I am trying to find the port number that clients receive openJMS messages on. After searching for ages on the web I can only find information about the server ports, nothing on the client. This is for a tcp connection.

If anyone can point me in the right direction I would be very grateful.

Thanks!

Was it helpful?

Solution

In general, the client port number will be different for each new connection. I could find no evidence that OpenJMS clients use specific port numbers when communicating with servers. Here are a few explanations.

  1. Port Numbers

    When a client process first contacts a server process, it may use a well-known port number to initiate communication. Well-known port numbers are assigned to particular services throughout the Internet, by IANA, the Internet Assigned Numbers Authority. The well-known port numbers are in the range 0 through 1023.

    Well-known ports are used only to establish communication between client and server processes. When this has been done, the server allocates an ephemeral port number for subsequent use. Ephemeral port numbers are unique port numbers which are assigned dynamically when processes start communicating. They are released when communication is complete.

  2. TCP/IP Client (Ephemeral) Ports and Client/Server Application Port Use

    In contrast, servers respond to clients; they do not initiate contact with them. Thus, the client doesn't need to use a reserved port number. In fact, this is really an understatement: a server shouldn't use a well-known or registered port number to send responses back to clients. The reason is that it is possible for a particular device to have both client and server software of the same protocol running on the same machine. If a server received an HTTP request on port 80 of its machine and sent the reply back to port 80 on the client machine, it would be sending the reply to the client machine's HTTP server process (if present) and not the client process that sent the initial request.

    To know where to send the reply, the server must know the port number the client is using. This is supplied by the client as the Source Port in the request, and then used by the server as the destination port to send the reply. Client processes don't use well-known or registered ports. Instead, each client process is assigned a temporary port number for its use. This is commonly called an ephemeral port number.

  3. Similar answer on another question: How to decide on port number between client and server communication on internet:

    Also, a client can connect to many servers on the same port. When the clients connect, they will use a random port on there end.

    Only the server needs to worry about using a free port, and the clients need to know what this port is else they will not be able to connect to your server.

Other possible help:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top