local port
is nothing but a socket descriptor (or a very high numbered port)
Whenever a process makes an API call, the request, via the kernel, creates a socket descriptor so as to bind (and identify) this particular request's response.
Any outbound call results in a socket being created and when the response arrives at the NIC (network interface) and then to kernel, the kernel figures out the destination application for this response.
This is done by checking the port which has a ono-one mapping to the process running (pid). Then it checks the socket descriptor value attached in the response meta (this value is passed on when creating a connection) and sends the response stream to the socket buffer.
The CPU then wakes the process to collect the response.
So answering your main question,
local port
is nothing but a socket descriptor
- ideally if there is no virtualisation and you own the hardware, you should be able to. connect to it via ip. But generally that is not the case and a lot of NAT (network address translation) goes in which might prevent this
try, ls -li /proc/<pid>/fd/
to see all the open socket descriptors
where is your application process-id