TCP Client Server Communication

How do you communicate through internet ? what protocol do you use ? How the connection is established ?


Well , today we are going to see about establishing a simple tcp connection between client and the server .

In the client side , we are gonna to establish a connection with server (send a request )

For that we need to do 3 things ,
1.socket() -- create a socket .
2.connect() -- make a connection with the server .
3.recv() -- for receving data from server .  

below picture tells the needs for tcp client .



In tcp server , we are going get the response from the client and response to it .
For establishing a tcp server connection we need to do 4 things ,
1: socket() -- create a socket connection .
2: bind() -- bind with ip , server_address , port .
3: listen() -- listen for any connections that are active .
4: accept() -- for accepting the client request .


For video reference : tcp client
tcp server

Comments

Popular posts from this blog

What is the best way to learn Programming ?