Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What are the steps that are followed when two computers connect through TCP?
Home
JAVA
What are the steps that are followed when two computers connect through TCP?
+1
vote
asked
May 7, 2021
in
JAVA
by
sharadyadav1986
What are the steps that are followed when two computers connect through TCP?
#socket-programming
tcp
Java-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
May 7, 2021
by
sharadyadav1986
There are the following steps that are performed when two computers connect through TCP.
The ServerSocket object is instantiated by the server which denotes the port number to which, the connection will be made.
After instantiating the ServerSocket object, the server invokes accept() method of ServerSocket class which makes server wait until the client attempts to connect to the server on the given port.
Meanwhile, the server is waiting, a socket is created by the client by instantiating Socket class. The socket class constructor accepts the server port number and server name.
The Socket class constructor attempts to connect with the server on the specified name. If the connection is established, the client will have a socket object that can communicate with the server.
The accept() method invoked by the server returns a reference to the new socket on the server that is connected with the server.
...