13695_tcp client algorithm
TRANSCRIPT
-
8/12/2019 13695_TCP Client Algorithm
1/10
Socket Programming
Jignesh Patel
Palanivel Rathinam
connecting processes
-
8/12/2019 13695_TCP Client Algorithm
2/10
Overview
Introduction to Sockets A generic Client-Server application References
-
8/12/2019 13695_TCP Client Algorithm
3/10
Introduction to Sockets
-
8/12/2019 13695_TCP Client Algorithm
4/10
Introduction to Sockets
Why Sockets? Used for Interprocess communication.
The Client-Server model Most interprocess communication uses client-server model Client & Server are two processes that wants to communicate with each
other The Client process connects to the Server process, to make a request for
information/services own by the Server. Once the connection is established between Client process and Server
process, they can start sending / receiving information.
What are Sockets? End-point of interprocess communication. An interface through which processes can
send / receive information
Socket
-
8/12/2019 13695_TCP Client Algorithm
5/10
Introduction to Sockets
What exactly creates a Socket? tuple
What makes a connection?
{Source , Destination } i.e. sourcesocket destination socket pair uniquely identifies a connection.
Example
Server
Client
Client
192.168.0.1
192.168.0.2
192.168.0.2
80
1343
5488
Client192.168.0.31343
-
8/12/2019 13695_TCP Client Algorithm
6/10
Introduction to Sockets
Socket Types STREAM uses TCP which is reliable, stream oriented protocol
DATAGRAM uses UDP which is unreliable, message oriented protocol
RAW provides RAW data transfer directly over IP protocol (no transportlayer)
Sockets can use unicast ( for a particular IP address destination)
multicast ( a set of destinations 224.x.x.x)
broadcast (direct and limited)
Loopback address i.e. 127.x.x.x
-
8/12/2019 13695_TCP Client Algorithm
7/10
A generic Client-Server application
-
8/12/2019 13695_TCP Client Algorithm
8/10
A generic TCP application
algorithm for TCP client Find the IP address and port number of server Create a TCP socket Connect the socket to server (Server must be up and listening for new
requests)
Send/ receive data with server using the socket Close the connection
algorithm for TCP server Find the IP address and port number of server Create a TCP server socket
Bind the server socket to server IP and Port number (this is the port to whichclients will connect)
Accept a new connection from client returns a client socket that represents the client which is connected
Send/ receive data with client using the client socket
Close the connection with client
-
8/12/2019 13695_TCP Client Algorithm
9/10
A generic UDP application
algorithm for UDP client Find the IP address and port number of server Create a UDP socket Send/ receive data with server using the socket Close the connection
algorithm for UDP server Find the IP address and port number of server Create a UDP server socket Bind the server socket to server IP and Port number (this is the port to which
clients will send) Send/ receive data with client using the client socket
Close the connection with client
-
8/12/2019 13695_TCP Client Algorithm
10/10
References
Man pages in LinuxAccesssible through following command man 2 E.g. man 2 socket
Unix network programming by Richard Stevens Beejs guide to Network Programming
http://beej.us/guide/bgnet/ The Java Tutorial Custom Networking
http://java.sun.com/docs/books/tutorial/networking/ Lecture notes of cs423 from Dr. Bob Cotter
http://www.sce.umkc.edu/~cotterr/cs423_fs05/cs423_fs05_lectures.html
http://beej.us/guide/bgnet/http://java.sun.com/docs/books/tutorial/networking/http://www.sce.umkc.edu/~cotterr/cs423_fs05/cs423_fs05_lectures.htmlhttp://www.sce.umkc.edu/~cotterr/cs423_fs05/cs423_fs05_lectures.htmlhttp://java.sun.com/docs/books/tutorial/networking/http://beej.us/guide/bgnet/