I always thought I had a good grasp on this, but just discovered something that leaves me puzzled. I'm don't know what to make of this or understand it.
I know that when the listener receives a request on it's configured port, it hands of the connection to either a dedicated server (spawned by the listener for this connection) or a dispatcher, and gives the client a 'random high port'. But it was pointed out to me on another forum that this is the client's port and server continues to use 1521.
So I set up a little test. First I used SQL Dev to connect from my Windows latptop to a database running on a vm, which itself is running on my Ubuntu laptop. Checking the listener log, I get the port assigned for the connection:
20-JUL-2021 10:19:42 * (CONNECT_DATA=(CID=(PROGRAM=SQL Developer)(HOST=__jdbc__)(USER=edste))(SERVICE_NAME=pdb01.localdomain)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.88)(PORT=50450)) * establish * pdb01.localdomain * 0
Then checked that with netstat:
oracle:cdb$ netstat -an |grep 50450
tcp6 0 0 192.168.100.200:1521 192.168.100.88:50450 ESTABLISHED
Next, I stopped the listener, then ran a query from SQL Dev to confirm the connection was not dependent on the listener - which I knew it wasn't. After that, with the listener still down I tried netstat again:
oracle:cdb$ lsnrctl stop
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 20-JUL-2021 10:21:39
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
2021-07-20 10:21:39
oracle:cdb$ set -o vi
2021-07-20 10:21:43
oracle:cdb$ netstat -an |grep 50450
tcp6 0 0 192.168.100.200:1521 192.168.100.88:50450 ESTABLISHED
So my question is (and it may be the wrong question, based on my misunderstanding), if the client is connected to the dedicated server via port 1521, and with the listener still running and polling 1521, then when the client sends a net message to the server port 1521, how is it sorted out who - the listener or the dedicated server - receives and handles it?