 Hello and welcome to the session on communication using UDP. At the end of this session, students will be able to introduce client server communication using connectionless iterative service offered by UDP. Unix Socket Programming Sockets are communication points on the same or different computers to send and receive data. Unix are supported by Unix, Windows or Mac OS and many other operating systems. What is a socket? Sockets allow communication between two different processes on the same or different machines. For more likely, it's a way to talk to other computers using standard Unix file descriptors. In Unix, every IO action is done by writing or reading a file descriptor. A file descriptor is just an integer associated with an open file and it can be a network connection, a text file, a terminal or something else. To a programmer, a socket looks and behaves much like a low-level file descriptor. This is because commands such as read and write work with sockets in the same way they do with the files and pipes. The sockets feature is now available with most current Unix system releases. A Unix socket is used in a client server application framework. A server is a process that performs some functions on request from a client. Most of the applications' level protocols like FTP, SMTP and POP3 make uses of the socket to establish connection between client server and then exchanging data. Address classes. IP addresses are managed and created by the Internet Authority of Assigning Names and Numbers i.e. ICANN. There are five different address classes. You can determine which class of IP is in by examining the first four bits of the IP addresses. Class A address begins with the 1 to 126 decimal, Class B address begins with 128 to 191 decimal, Class C address begins with 192 to 223 decimals, Class D address begins with 224 to 239 decimals, Class C address begins with 240 to 254 decimal client server model. Most of the net applications use the client server architecture which refers to two processes or two applications that communicate with each other to exchange some information. One of the two processes acts as a client process and another process acts as a server process, the client process. So this is the process which typically makes a request for information. After getting the response, this process may terminate or may do some other processing. For example, Internet Browser works as a client application which sends a request to the web browser to get one HTML page, the server process. So this is the process which takes a request from the client after getting a request from the client. This process will perform the required processing. It gather requested information and send it to the requester client. Once doing this, it becomes ready to serve another client, server processes are always alert and ready to serve incoming requests. For example, web server keeps waiting for requests from internet browsers and as soon as it gets any request from a browser, it picks up a requested HTML page and send it back to that browser. The systems calls for establishing a connection are somewhat different for the client and the server. But both involve the basic construct of a socket. Both the processes establish their own sockets. So here are some steps involved in establishing a socket. On the client side, create a socket with the socket system call. Connect the socket to the address of the server using the connect system call. Then send to and receive from data, there are number of ways to do this. But the simplest way is to use the send to and receive from functions. How to make server? So here are some steps involved in establishing a socket on the server side. First create a socket with socket system call. Then bind the socket to an address using the bind system call. For a server socket on the internet, an address consists of a port number on the host machine. Listen for connection with the listen system call. Then accept a connection with the accept system call. This call typically blocks the connection until a client connects with the server. At the end, send and receive data using read and write system calls or send to and receive functions. So here the figure shows the flow diagram for communication using UDP. The server process. The server process starts first. The server process calls the socket function to create a socket. Then it calls the bind function to bind the socket to its well-known port and then IP address to the computer on which the server process is running. The server then calls the receive from function which blocks until a datagram arrives. When the datagram arrives, the receive from function unblocks and extracts the client socket address and address link from the received datagram and returns them to the process. The process saves these two pieces of information and calls a procedure to handle the request. When the result is ready, the server process calls the send to function and use saved information to send to the result to the client that requested it as shown in the figure. The server uses an infinite loop to respond to the request coming from the same client or on different clients. The client process. The client process is simple. The client calls the socket function to create a socket. Then it calls the send to function to pass the socket address of the server and the location of the buffer from which the UDP can get data. The client then calls the receive from function calls that blocks until the reply arrives from the server. When the reply arrives, the UDP delivers the data to the client process which makes the receive function to unblock and delivers the data received to the client process. Here you can assume that the client message is so small so that it can fit into a single datagram. If the client message is too large, then we have to need two function calls send to and receive from. The server is not aware of multi-datagram communication. It handles each request. So the variables use in the client process and the variables use in the server process. Here you can see the program for Ecoserver. Here you can see in line 14 creates a socket. At line 16 to 19, create the local socket address. The remote socket address will be created in line 24. Line 20 binds the socket to the local socket address. Line 22 to 26 receive and send datagrams. It can be from many clients. When the server receives a datagram from a client, the client socket address and the length of the socket address are returned to the server. Here you can see the client program and ECO client process. Here we assume that the client send only one datagram to the ECODE by this. Here line 12 creates a socket. Lines 14 to 17 show how to create the server socket address and there is no need for create the client socket address here. Lines 19 to 25 read a string from the keyboard and send it to the server and receives it back. Line 23 adds a null character to the received string to make it visible in line 25. In line 27 we are going to close the socket. Here pause the video think and answer. The answer is A that is sent to. Here are my references. Thank you.