 Hello and welcome to the session on the socket interface part one. At the end of this session, students will be able to introduce socket interfaces and list some common functions in this interface. So how can a client process communicate with a server process? A computer program is a set of redefined instructions that tells the computer what to do. A computer program has a set of instructions for mathematical operations, another set of instructions for string operations, still another set of instructions for input or output access. If we need a program to be able to communicate with the another program running on another machine, so we need a new set of instructions which tells the transport layer to open the connection, then send data to and receive data from the other end and close the connection. A set of instructions of such kind is normally referred as an interface. An interface is a set of instructions designed for interaction between two entities. There are several interfaces have been designed for communication. Three among them are common, socket interface, transport layer interface and stream, so that the programmer must be familiar with these kind of interfaces. Socket interface started in early 1980s at the University of Berkeley as a part of Unix environment. To better understand the concept of socket interface, here we need to consider the relationship between the operating system such as Unix or Windows and the TCP IP protocol suit. Here this figure shows the conceptual relation between the operating system and the protocol suit. So here you can see the socket interface. Socket interface is a set of instructions which is located between the operating system and the application program. To access the services provided by TCP IP protocol suit, an application needs to use the instructions defined in the socket interface. For example, most of the programming languages have a file interface as a set of instructions that allow the programmer to open a file, to read from the file, to write into the file, perform some other operations on the file and finally close. When a program needs to open the file, so it uses the name of the file as it is known to the operation system. When the file is opened, the operating system returns a reference to the file. As an integer or pointer that can be used for other instructions such as read and write. So here the concepts of socket. A socket is a software abstract simulating a hardware socket. That is what in our daily life. To use the communication channel, an application program may be client or server needs to request the operating system to create a socket. The application program then can plug into the socket to send and receive data. As you can see in this particular diagram, the client process at the client side and the server process at the server side. So they need to plug into the socket for two-way communication. So to have a communication, an application program either may be client or server needs to request the operating system to create a socket. For data communication, a pair of socket at each end for the communication is to be needed. So you can see here a pair of socket at the client side and pair of socket at the server side for two-way communication it is required at each end. The figure shows the concepts of the socket. So such kind of abstraction using the socket and plug that we are going to use in our daily life like a telephone. The telephone to be connected into the socket so that it could be communicated to the other end. Now data structures, the format of data structure to define socket depends on the language used by the processes. Here we are going to writing the client server code in C language. So in C language a socket is defined as five field structure. You can see here in C language the socket is going to be defined as the five fields. Here you have to note that the programmer should not redefine this structure it is already defined in the system. The programmer needs only use the header file that includes this definition. So let us here briefly define the fields uses in this particular structure. So as you can see the fields there are five fields in the data structure and the generic definition of this particular data structure shown here in this particular diagram. It is a structure, the socket structure and it has family type protocol then local socket address, remote socket address these are the fields. So let us define each field. The first field is family. So this field defines the protocol group either IPv4, IPv6, UNIX domain protocols. The first field is family. So this field defines the protocol group either IPv4, IPv6, UNIX domain protocols or so on. The family we can use in this TCP IP protocol suit defined by the constant like if INET for IPv4 protocol and if INET6 for IPv6 protocol. Second field is type. This field defines four types of socket. As you can see here in type there are four socket types. The first is shock stream. The first is shock stream which is used for TCP. Second is shock datagram which is used for UDP protocol. Third is shock sequence packet which is used for STP. Stream control transmission is shock raw. The shock raw for the applications those who are directly use the services. This field defines the local socket address. A socket address is a combination of IP address and port number. Remote socket address. This field defines the remote socket address. Before we move forward and use socket we need to understand the structure of a socket address and a combination of IP address and port number. So as there are several types of socket addresses have been defined in a network programming. So we need to define the one which is used for IPv4. So here you can see here in this particular structure of a socket address. The socket address is being defined here and with five fields. So here in this particular version of socket address which is a complex data structure which is used in C as shown in this particular diagram. Here note that the struct socket address in has five fields but in syn address field it is itself a struct of type. Here note that the struct socket address in has five fields but the syn address fields itself a structure of type in address with one single field S address in it. So here we are going to define first the structure in address like this. The structure in address is so you can see here the in address having S address field which is a 32 bit IPv4 address. The single field in that the struct in address. Then structure socket address which has five fields. The syn length which is the length of the structure 16 bytes. Then the syn family which is set to AF INET. Then syn port which is 16 bit port number. Then syn address which is 32 bit IPv4 address. Then character syn0 which is unused. Here pause the video thing and answer. The answer is C. Here is the reference. Thank you.