OpenJMS - Client port number - client

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!

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.
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.
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.
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:
How to find number of ephemeral ports in use?

Related

FTP server use single port to serve all clients ? how does it differentiate data for each client?

A server, say for example an FTP server is listening on a port 21. Multiple clients can connect to it simultaneously and get ftp services asynchronously without being blocked.
My assumption is that the server has a separate thread to handle each client request. (Question: Does the new thread start negotiating new port with this client or continue using the same port (21) for data exchange ?)
my understanding is that the server uses a single port (21) to serve all the clients, including new connection requests.
if that is the case how does the server using a single port differentiates between clients and how does it delegate relevant data for each relevant thread ?
The same was as any other TCP/IP server.
Each client have a unique IP address and/or a port number.
The combination of client address and port and server address and port creates a virtual channel. The channel is used to exchange data between client and server software running on different machines. This is typically built into OS. The client and server software does not have to handle it specifically.

Requests from server to client

I know already about the web-sockets, and they are great, the problem with them is that they have to keep the connection open in order to be able to communicate.
I have a small system where from time to time the server has to update the status and notify the clients about that, and keeping the connection open from every client is not so optimal. At same time is very important that the update on the client side to be made just in time.
So my question is, if the server has a unique address does the client have a public temporary address where the server can send request? So when the client will connect to the server it will provide it's unique address and the server will cache it, and when there will be an update the server will send the request to that address?
I understand that there many problems as the address will constantly change, but this is already other question.
If client does not have a dedicated IP-address then it is not available from WAN unless it has an open connection with any node in it.
When client from local network sends request to a server it's (client's) router remembers client's local IP-address and port and translates it using NAT protocol to one of router's free ports and then sends data further with router's own 'IP-address of the sender' in IP protocol header and 'Sender's port' in TCP header. When router get's server's response it uses NAT table from it's memory to translate addresses back and deliver data to the client. Addresses are normally kept in NAT table while connection between server and client is open. So if there are no opened connections between server and local network client then server will not be able to connect with client because server does not know how to reach it.
You say you have a small system. Why then do you think that you will not have enough free ports at your server to work with websockets? If you just want to get updates from the server (not to both send and get data through a persistently opened connection) you'll probably find long polling or SSE more suitable. It is definitely easier to implement than websockets.

Why browsers can receive incoming connections and other soft's cant!?

my question is simple
When you send data through TCP/IP protocol with EX:firefox you can receive reply on some random port that the browser listen on, while when i try to use a port for another task like CS Gaming or anything else it don't work unless i use kind of VPN ?
PS: there r no firewall blocking connection and port forwarding from my router didn't work as well.
Browsers are client apps that make outbound connections to web servers. When connecting to a server through a router’s NAT, the NAT takes note of the source and destination IP/port pairs so messages sent back from the server on the same connection are automatically routed to the correct client IP/port.
Browsers also support the websocket protocol. This feature makes it seem like the browser is listening on a specific port. However, in reality, it is initiated on a new connection to the server, a connection which remains open all throughout the websocket communication.
What matters is which peer is behind the NAT — the server or the client. For an outbound connection from a client, it can usually use any random port that is available at the time. For an inbound connection to a server, the server's IP/port must be known ahead of time and be routable. If the server is behind a NAT, the router(s) must be configured to make the server reachable from the other side of the NAT.
The server software can make a UPnP request to ask a router to forward inbound packets to the correct IP/Port. The router, depending on its configuration, may or may not honor such a request. If not, the router has to be configured manually by a network administrator.

What exactly is X11 Channel

In all the documentations of X11 that I've found so far something like this is written
Communication between server and clients is done by exchanging packets over a channel. The connection is established by the client (how the client is started is not specified in the protocol). (from wikipedia)
I haven't been able to find what is this channel exactly? A network channel for example? Is it on a port? Is it a memory map? Any help is appreciated.
The phrasing of 'channel' is intentionally vague as it can be either over a local socket, a remote connection (such as SSH), a named pipe, or another method that allows client/server bidirectional communication. Which is to say, a 'channel' is simply a connection between two points that facilitates exchange of data.
When perform X11 forwarding over SSH, the channel is the SSH connection. See the SSH man page for example:
$ man ssh
X11 connections and arbitrary TCP/IP ports can also be forwarded over the secure channel.
or per the x.org documentation:
The communications channel between an X client and server is full-duplex: either side can send a message to the other at any time. This is canonically implemented over a TCP/IP socket interface, though other communications channels are often used, including Unix domain sockets, named pipes and shared memory. The channel must provide a reliable, ordered byte stream---the X protocol provides no mechanism for reordering or resending packets.
X11 support multiple forms of communication between client and server. These so called channels can be TCP sockets, UNIX sockets, and a bunch of other network mechanisms, such as DECnet, token ring etc. TCP and UNIX sockets are really the only ones used today.
The X server is a process that has access to the graphics hardware, keyboard, and mouse. Any application that produces graphics on the computer screen is called a client. Usually, a workstation has on X server running, and multiple X clients. The applications (clients) need to connect to the X-Server via a TCP socket (identified by IP address and port number) or via a UNIX socket (identified by a file name, e.g. /tmp/X0)
If both, server and clients, run on the same system they usually connect through the UNIX socket. However, one of great features of X11 is that server and clients do not have the reside on the same system, but rather connect through the network via TCP sockets. This allows us to run applications on different computers on the network, and bring their graphics output on a single screen. (A single application may also connect to multiple X server and distribute graphics content on multiple screens.)

Socks 4 Bind Request Explanation

i was reading this topic
http://ftp.icm.edu.pl/packages/socks/socks4/SOCKS4.protocol
and what im trying to do is:
i have a client/server application, what im trying to do is to use socks 4 BIND request to bind my server to a remote socks server, and make the clients connect to that socks server and the socks server will make them connect to my server (at least thats how i understand socks BIND request)
but i don't fully understand it (my English is kinda bad), what im asking is, is it possible to do so when i dunno any of the remote IPs of the clients? since the server's BIND request package must contain the address of the remote client and i dont really have than since the clients are from unknown users retrieving status info from my server (or can i use 0 for INANY_ADDR) ?
What you are asking for is not possible with SOCKS, nor is it meant for that purpose. Read the spec again more carefully. The BIND command is meant for use with multi-connection protocols (like FTP), where a primary connection is used to communicate between a client and a server, and BIND facilitates situations where the server needs to connect a secondary connection to the client after the client tells the server where to connect. In that situation, the client would issue a BIND command to SOCKS telling it the server's IP/Port so it only accepts that connection, then send the resulting SOCKS listening IP/Port to the server to connect to.
What you are asking for is better served by using a router with Port Forwarding rules defined. Then you can open a listening port on the router that accepts any inbound connection and forwards it to your app's listening IP/Port. Most modern routers support uPNP (Universal Plug-N-Play) so you can configure the forwarding rules programmably instead of requiring admin access to the router's configuration software.

Resources