What happens when an Oracle client issues a request to connect to a database e.g
sqlplus scott/tiger@ora10g.localdomain
Here SQLPLUS is the client program, scott/tiger is the username/password and ora10g.localdomain is a TNS service name. TNS stans for Transparent Network Substrate and is a foundation software built into Oracle client to handle remote connections and allowing peer-to-peer communication. The TNS connection string tells the Oracle software how to connect to the remote database. Generally, the client software will read a configuration file "tnsnames.ora" which contains the details such as hostname, port number and the service name of the database on the host to which we wish to connect. A sample TNS entry:
gaurav_ora =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora10g)
)
)
Here host machine is localhost and "ora10g" is the database service name. 1521 is the port number on which a "TNS listener" process will accept connections.
So now, our client software knows where to connect to. It will open a TCP/IP socket connection to the server with the hostname localhost on port 1521. The TNS Listener process inspects this request and using its own configuration file either accepts or rejects the request.