Network Programming GNDU MSc IT Computer Science Study Material ebook Lecture Notes pdf Online Download|Neeraj K Anand|Anand Technical Publishers
Author’s Words
I strongly believe that the Almighty God alone plans every thing that happens in the world. So, I sincerely thanks the Almighty God for showering his blessings upon me and using me to write this book.
I wish to express my deep sense of gratitude to my colleagues and students whom encouragement and co-operation have been source of great inspiration to me. I am thankful to my father Sh. Om Prakash Anand, my son Param Anand and my dear wife Neetu Anand for bringing me out this book. I hope that this edition of the book will prove to be more useful to the Science and Engineering students. Any suggestions for further improvement of the book will be gratefully acknowledged by the both author and publisher. Finally, we would like to thank my colleagues in the various Institutes whom have encouraged and assisted us to make our best efforts in bringing out this book.
NIT – Warangal, Telangana
Neeraj K. Anand
October 2021
Dedication
In The Everlasting Memory of My Mother
Late Smt. Nirmal Anand
[embedyt]https://www.youtube.com/watch?v=-DNw7iybADw[/embedyt]
About The Book
A comprehensive Network Programming Book covers the topic of network sockets, implementing Internet Protocols, Inter Process Communication, Socket Programming, Communication Protocols and Transport Layer Interface Concepts etc. This Book is for M.sc Computer Science & Information Technology Students who were study in Guru Nanak Dev University. The objective of this book will provide the basic knowledge of the paradigms of Network Programming so that student able to understand the topics of Berkley socket, TLI, FIFO, UNIX command Structure, Shell Programming, UNIX Signals etc. Second Objective of this book is to familiarize students with advanced concepts of Networks, Network Programming in UNIX Environment.
This book covers core concepts, such as hostname resolution with DNS, that are very useful to the functioning of the latest web technology. You’ll study into the fundamental network protocols, TCP and UDP. Essential techniques for networking technology such as client-server and peer-to-peer models are explained in very simple way. You’ll also study HTTP and HTTPS from both the client and server perspective. To keep up with current trends, you’ll apply the concepts covered in this book to gain insights into network programming for IoT. You’ll even get to grips with network monitoring and implementing security best practices. By the end of this book, you’ll have experience of working with client-server applications, and be able to implement new network programs.
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Syllabus (M.Sc. Computer Science – 3rd Semester (GNDU)
Sockets and Socket Address structures, Concept of Zombies, Daemon Processes, Super servers, Concurrent versus Iterative servers, Protocol Independence, Error Handling : Wrapper functions, OSI Model, Unix standards.
TCP Connection establishment & Termination, Port Numbers and Concurrent Servers, Protocol Usage by common Internet Applications.
UDP Communication Semantics, UDP Echo Server, Echo Client working, Protocol Usage by Common Internet Applications.
Sockets Address Structures, Byte ordering & Manipulation Functions, TCP Socket System Calls, TCP Client-Server E.g., I/O Multiplexing, Signal Handling in Concurrent Servers.
Socket Options, Elementary Names Address Conversions, Ipv4 and Ipv6 Interoperability.
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.1 : Elementary Unix Sockets
Network Programming……………………………………………………………………………. 9
What is a Socket ?……………………………………………………………………………………. 11
Where is Socket used ?……………………………………………………………………………. 11
Explain different types of sockets…………………………………………………….. 14
Explain Socket Descriptors. write Socket communication domains…………………………………………………………………………………………………………………….. 14
how to Specifying An Endpoint Address for Socket ?………………………. 15
Explain the characteristics of different unix Socket types……….. 16
How file descriptor functions act with sockets ? Write the way to terminate the socket…………………………………………………………………………….. 17
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.2 : Unix Socket Address Structures
discuss briefly unix Socket Address Structures…………………………….. 19
discuss IPv4 & generic Socket Address Structure……………………………. 19
discuss IPv6 & generic Socket Address Structure……………………………. 22
Differentiate between socket address structures of IPv4, IPv6, Unix domain, datalink, and storage…………………………………………………… 23
how to Socket address structure passed from process to kernel and kernel to process ?…………………………………………………………………………. 24
Why must value-result arguments such as the length of a socket address structure be passed by reference?…………………………………….. 24
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.3 : Concept Of Zombies & Daemon Processes
what do mean by zombie process ? Explain briefly…………………………. 26
WHAT ARE Daemon Processes ? WRITE THE METHODS TO START A DAEMON……………………………………………………………………………………………………… 27
WHAT IS THE FUNCTION OF syslogd Daemon ?………………………………………… 27
WHAT PERFORM syslog FUNCTION ? discuss the levels and facilities of log messages………………………………………………………………………………………. 28
discuss the technique to daemonizes the process using daemon_init Function…………………………………………………………………………………………………… 30
discuss inetd Daemon using telnet server. why its is called a internet server ?…………………………………………………………………………………….. 34
discuss the various steps performed by inetd Daemon to execute a server……………………………………………………………………………………………………….. 37
discuss inetd Daemon descriptors when a new connection request arrives from a FTP client……………………………………………………………………… 39
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.4 : Concurrent And Iterative Servers
what do you mean by client and server. Discuss Concurrent and Iterative servers. Write their advantages and disadvantages. Also differentiate them……………………………………………………………………….. 43
discuss wrapper functions to handle errors occur in unix networking program…………………………………………………………………………….. 52
what do you mean by Concurrency And Asynchronous I/O…………… 53
Chapter.5 : Study Of OSI Model And Unix Standards
osi Model……………………………………………………………………………………………………… 55
Unix Standards…………………………………………………………………………………………… 56
Chapter.6 : TCP Communication Between Client And Server
discuss the techniques to establish and terminate the TCP connection between client and server…………………………………………….. 58
TCP State Transition Diagram………………………………………………………………….. 61
explain the packets exchange operation during tcp connection establishment and termination………………………………………………………….. 63
TCP Port Numbers And Concurrent Servers………………………………………….. 64
Protocol Usage by Common Internet Applications…………………………….. 66
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.7 : udP Communication Between Client And Server
Elementary UDP Sockets…………………………………………………………………………… 68
recvfrom And sendto Functions………………………………………………………………… 69
UDP Echo Server : main Function………………………………………………………………. 70
discuss Simple echo client/server using UDP…………………………………….. 70
UDP Echo Server : dg_echo Function………………………………………………………… 71
UDP Echo Client : main Function……………………………………………………………….. 73
UDP Echo Client: dg_cli Function……………………………………………………………. 74
Lost Datagrams………………………………………………………………………………………….. 75
Verifying Received Response……………………………………………………………………. 75
what will happen when starting the client without starting the server……………………………………………………………………………………………………….. 77
Network Programming GNDU Study Material ebook Download. GNDU Msc Computer Science ebooks download. Buy GNDU Msc Computer Science Network Programming Book. Download GNDU free ebooks to teach online. Best Online teaching app & website.
Chapter.8 : Socket Address Structures
Byte Ordering Functions………………………………………………………………………….. 79
explain the functions used to convert processor byte order into network byte order for TCP/IP applications…………………………………….. 80
Byte Manipulation Functions………………………………………………………………….. 83
inet_aton, inet_addr, And inet_ntoa Functions………………………………….. 84
explain the functions that are used to convert internet addresses between ascii strings and network byte ordered binary values………………………………………………………………………………………….. 84
inet_pton And inet_ntop Functions………………………………………………………… 85
sock_ntop And Related Functions…………………………………………………………… 87
what is the disadvantage of inet_ntop function……………………………. 87
readn, writen, And readline Functions……………………………………………….. 89
Chapter.9 : Elementary TCP Sockets And TCP Socket
System Calls
Major System Calls Used With Sockets…………………………………………………. 94
Elementary TCP Sockets…………………………………………………………………………… 96
Socket Function………………………………………………………………………………………….. 98
AF_xxx Versus PF_xxx………………………………………………………………………………….. 99
Connect Function……………………………………………………………………………………… 100
bind Function……………………………………………………………………………………………. 101
listen Function……………………………………………………………………………………….. 103
accept Function……………………………………………………………………………………….. 106
fork Function……………………………………………………………………………………………. 108
exec Function……………………………………………………………………………………………. 109
Concurrent Servers………………………………………………………………………………… 111
close Function…………………………………………………………………………………………… 113
getsockname And getpeername Functions……………………………………………. 114
Chapter.10 : TCP Client/Server Communication
Functions
TCP Client/Server Communication…………………………………………………………. 117
Normal Session Startup………………………………………………………………………….. 121
Normal Session Termination………………………………………………………………….. 122
POSIX Signal Handling……………………………………………………………………………… 124
POSIX Signal Semantics…………………………………………………………………………….. 126
SIGCHLD Signals…………………………………………………………………………………………. 126
wait And waitpid Functions…………………………………………………………………. 128
difference between wait and waitpid Functions……………………………. 129
A Connection Abort Before accept Returns………………………………………… 132
Termination of Server Process……………………………………………………………… 134
SIGPIPE Signal…………………………………………………………………………………………… 135
Crashing of Server Host…………………………………………………………………………. 136
Crashing and Rebooting of Server Host……………………………………………… 137
Shutdown of Server Host……………………………………………………………………….. 137
Chapter.11 : I/O Multiplexing And Signal Handling
In Concurrent Servers
under what situations i/o Multiplexing is used in network applications ?
which functions are capable for i/o Multiplexing ?……………………… 138
I/O Models…………………………………………………………………………………………………… 138
discuss the five basic i/o models of unix………………………………………….. 138
Comparison of the I/O Models…………………………………………………………………. 142
select Function…………………………………………………………………………………………. 143
Under What Conditions Is a Descriptor Ready?………………………………. 146
str_cli Function………………………………………………………………………………………. 148
Batch Input and Buffering……………………………………………………………………… 150
shutdown Function…………………………………………………………………………………….. 152
TCP Echo Server…………………………………………………………………………………………. 153
discuss with example the behaviour of tcp server before and after the clients have establish a connections……………………………. 153
pselect Function………………………………………………………………………………………. 157
poll Function…………………………………………………………………………………………….. 159
Chapter.12 : Elementary Names Address Conversions
discuss the methods to convert names into numeric addresses for communication……………………………………………………………………………………… 162
gethostbyname Function………………………………………………………………………….. 163
gethostbyaddr Function………………………………………………………………………….. 165
Getservbyname And Getservbyport Functions…………………………………….. 166
Chapter.13 : Interoperability Between IPv4 And
IPv6 servers
discuss the techniques for Interoperability between IPv4 and IPv6 server……………………………………………………………………………………………………… 170
discuss the techniques for Interoperability between IPv6 client and IPv4 server………………………………………………………………………………………. 173
tabulate the Interoperability between IPv4 and IPv6 server……… 174
explain the IPv6 Address-Testing Macros………………………………………… 175
explain the Source Code Portability between IPv4 and IPv6………… 176
Chapter.1 : Elementary Unix Sockets
Network Programming……………………………………………………………………………. 9
What is a Socket ?……………………………………………………………………………………. 11
Where is Socket used ?……………………………………………………………………………. 11
Explain different types of sockets…………………………………………………….. 14
Explain Socket Descriptors. write Socket communication domains…………………………………………………………………………………………………………………….. 14
how to Specifying An Endpoint Address for Socket ?………………………. 15
Explain the characteristics of different unix Socket types……….. 16
How file descriptor functions act with sockets ? Write the way to terminate the socket…………………………………………………………………………….. 17
Chapter.2 : Unix Socket Address Structures
discuss briefly unix Socket Address Structures…………………………….. 19
discuss IPv4 & generic Socket Address Structure……………………………. 19
discuss IPv6 & generic Socket Address Structure……………………………. 22
Differentiate between socket address structures of IPv4, IPv6, Unix domain, datalink, and storage…………………………………………………… 23
how to Socket address structure passed from process to kernel and kernel to process ?…………………………………………………………………………. 24
Why must value-result arguments such as the length of a socket address structure be passed by reference?…………………………………….. 24
Chapter.3 : Concept Of Zombies & Daemon Processes
what do mean by zombie process ? Explain briefly…………………………. 26
WHAT ARE Daemon Processes ? WRITE THE METHODS TO START A DAEMON……………………………………………………………………………………………………… 27
WHAT IS THE FUNCTION OF syslogd Daemon ?………………………………………… 27
WHAT PERFORM syslog FUNCTION ? discuss the levels and facilities of log messages………………………………………………………………………………………. 28
discuss the technique to daemonizes the process using daemon_init Function…………………………………………………………………………………………………… 30
discuss inetd Daemon using telnet server. why its is called a internet server ?…………………………………………………………………………………….. 34
discuss the various steps performed by inetd Daemon to execute a server……………………………………………………………………………………………………….. 37
discuss inetd Daemon descriptors when a new connection request arrives from a FTP client……………………………………………………………………… 39
Chapter.4 : Concurrent And Iterative Servers
what do you mean by client and server. Discuss Concurrent and Iterative servers. Write their advantages and disadvantages. Also differentiate them……………………………………………………………………….. 43
discuss wrapper functions to handle errors occur in unix networking program…………………………………………………………………………….. 52
what do you mean by Concurrency And Asynchronous I/O…………… 53
Chapter.5 : Study Of OSI Model And Unix Standards
osi Model……………………………………………………………………………………………………… 55
Unix Standards…………………………………………………………………………………………… 56
Chapter.6 : TCP Communication Between Client And Server
discuss the techniques to establish and terminate the TCP connection between client and server…………………………………………….. 58
TCP State Transition Diagram………………………………………………………………….. 61
explain the packets exchange operation during tcp connection establishment and termination………………………………………………………….. 63
TCP Port Numbers And Concurrent Servers………………………………………….. 64
Protocol Usage by Common Internet Applications…………………………….. 66
Chapter.7 : udP Communication Between Client And Server
Elementary UDP Sockets…………………………………………………………………………… 68
recvfrom And sendto Functions………………………………………………………………… 69
UDP Echo Server : main Function………………………………………………………………. 70
discuss Simple echo client/server using UDP…………………………………….. 70
UDP Echo Server : dg_echo Function………………………………………………………… 71
UDP Echo Client : main Function……………………………………………………………….. 73
UDP Echo Client: dg_cli Function……………………………………………………………. 74
Lost Datagrams………………………………………………………………………………………….. 75
Verifying Received Response……………………………………………………………………. 75
what will happen when starting the client without starting the server……………………………………………………………………………………………………….. 77
Chapter.8 : Socket Address Structures
Byte Ordering Functions………………………………………………………………………….. 79
explain the functions used to convert processor byte order into network byte order for TCP/IP applications…………………………………….. 80
Byte Manipulation Functions………………………………………………………………….. 83
inet_aton, inet_addr, And inet_ntoa Functions………………………………….. 84
explain the functions that are used to convert internet addresses between ascii strings and network byte ordered binary values………………………………………………………………………………………….. 84
inet_pton And inet_ntop Functions………………………………………………………… 85
sock_ntop And Related Functions…………………………………………………………… 87
what is the disadvantage of inet_ntop function……………………………. 87
readn, writen, And readline Functions……………………………………………….. 89
Chapter.9 : Elementary TCP Sockets And TCP Socket
System Calls
Major System Calls Used With Sockets…………………………………………………. 94
Elementary TCP Sockets…………………………………………………………………………… 96
Socket Function………………………………………………………………………………………….. 98
AF_xxx Versus PF_xxx………………………………………………………………………………….. 99
Connect Function……………………………………………………………………………………… 100
bind Function……………………………………………………………………………………………. 101
listen Function……………………………………………………………………………………….. 103
accept Function……………………………………………………………………………………….. 106
fork Function……………………………………………………………………………………………. 108
exec Function……………………………………………………………………………………………. 109
Concurrent Servers………………………………………………………………………………… 111
close Function…………………………………………………………………………………………… 113
getsockname And getpeername Functions……………………………………………. 114
Chapter.10 : TCP Client/Server Communication
Functions
TCP Client/Server Communication…………………………………………………………. 117
Normal Session Startup………………………………………………………………………….. 121
Normal Session Termination………………………………………………………………….. 122
POSIX Signal Handling……………………………………………………………………………… 124
POSIX Signal Semantics…………………………………………………………………………….. 126
SIGCHLD Signals…………………………………………………………………………………………. 126
wait And waitpid Functions…………………………………………………………………. 128
difference between wait and waitpid Functions……………………………. 129
A Connection Abort Before accept Returns………………………………………… 132
Termination of Server Process……………………………………………………………… 134
SIGPIPE Signal…………………………………………………………………………………………… 135
Crashing of Server Host…………………………………………………………………………. 136
Crashing and Rebooting of Server Host……………………………………………… 137
Shutdown of Server Host……………………………………………………………………….. 137
Chapter.11 : I/O Multiplexing And Signal Handling
In Concurrent Servers
under what situations i/o Multiplexing is used in network applications ?
which functions are capable for i/o Multiplexing ?……………………… 138
I/O Models…………………………………………………………………………………………………… 138
discuss the five basic i/o models of unix………………………………………….. 138
Comparison of the I/O Models…………………………………………………………………. 142
select Function…………………………………………………………………………………………. 143
Under What Conditions Is a Descriptor Ready?………………………………. 146
str_cli Function………………………………………………………………………………………. 148
Batch Input and Buffering……………………………………………………………………… 150
shutdown Function…………………………………………………………………………………….. 152
TCP Echo Server…………………………………………………………………………………………. 153
discuss with example the behaviour of tcp server before and after the clients have establish a connections……………………………. 153
pselect Function………………………………………………………………………………………. 157
poll Function…………………………………………………………………………………………….. 159
Chapter.12 : Elementary Names Address Conversions
discuss the methods to convert names into numeric addresses for communication……………………………………………………………………………………… 162
gethostbyname Function………………………………………………………………………….. 163
gethostbyaddr Function………………………………………………………………………….. 165
Getservbyname And Getservbyport Functions…………………………………….. 166
Chapter.13 : Interoperability Between IPv4 And
IPv6 servers
discuss the techniques for Interoperability between IPv4 and IPv6 server……………………………………………………………………………………………………… 170
discuss the techniques for Interoperability between IPv6 client and IPv4 server………………………………………………………………………………………. 173
tabulate the Interoperability between IPv4 and IPv6 server……… 174
explain the IPv6 Address-Testing Macros………………………………………… 175
explain the Source Code Portability between IPv4 and IPv6………… 176