27 Lecture

CS410

Midterm & Final Term Short Notes

Network Programming Part I

"Explore Network Programming Part I: Delve into socket communication, protocols (TCP/UDP), client-server interactions, and data exchange. Lay the foundation for creating efficient and secure networked applications."


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF

**Question 1:**

Which protocol is connection-oriented and provides reliable data transfer?

a) TCP

b) UDP

c) HTTP

d) IP

**Solution: a) TCP**


**Question 2:**

In network programming, what is a socket?

a) A physical connector for cables

b) A software endpoint for sending or receiving data across a computer network

c) A type of router

d) A type of firewall

**Solution: b) A software endpoint for sending or receiving data across a computer network**


**Question 3:**

Which function is used to create a socket in Python?

a) socket.socket()

b) create_socket()

c) new_socket()

d) socket.create()

**Solution: a) socket.socket()**


**Question 4:**

What is the default port number for HTTP?

a) 80

b) 443

c) 8080

d) 21

**Solution: a) 80**


**Question 5:**

Which networking protocol is connectionless and does not guarantee reliable data delivery?

a) TCP

b) UDP

c) FTP

d) SMTP

**Solution: b) UDP**


**Question 6:**

Which command is used to bind a socket to a specific address and port?

a) socket.connect()

b) socket.bind()

c) socket.listen()

d) socket.accept()

**Solution: b) socket.bind()**


**Question 7:**

What does DNS stand for in networking?

a) Domain Network Server

b) Data Naming System

c) Distributed Network Service

d) Domain Name System

**Solution: d) Domain Name System**


**Question 8:**

Which Python library is commonly used for network programming?

a) netlib

b) socketlib

c) networkpy

d) socket

**Solution: d) socket**


**Question 9:**

What does IP address uniquely identify in a network?

a) Domain name

b) MAC address

c) Port number

d) Device

**Solution: d) Device**


**Question 10:**

Which method is used to establish a connection in a TCP client socket in Python?

a) connect()

b) send()

c) accept()

d) bind()

**Solution: a) connect()**



Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF

**Question 1:**

Explain the difference between TCP and UDP protocols in terms of connection and reliability.


**Answer:**

TCP (Transmission Control Protocol) is connection-oriented and provides reliable data transfer through a handshake mechanism and acknowledgment. UDP (User Datagram Protocol) is connectionless and does not guarantee reliable data delivery, making it faster but less reliable.


**Question 2:**

What is a socket? How is it identified in a network?


**Answer:**

A socket is an endpoint for sending or receiving data across a computer network. It's identified by an IP address and a port number combination.


**Question 3:**

Describe the steps involved in establishing a TCP connection between a client and a server.


**Answer:**

1. Server creates a socket and binds it to an IP address and port.

2. Server listens for incoming connections.

3. Client creates a socket and connects to the server's IP address and port.

4. Server accepts the incoming connection request.

5. Client and server exchange data.


**Question 4:**

What is DNS? How does it work?


**Answer:**

DNS (Domain Name System) translates human-readable domain names into IP addresses that computers understand. It involves DNS servers that maintain a database of domain names and corresponding IP addresses.


**Question 5:**

Explain the purpose of the "bind" and "listen" functions in socket programming.


**Answer:**

The "bind" function associates a socket with a specific IP address and port. The "listen" function makes a socket a passive listener, allowing it to accept incoming connection requests.


**Question 6:**

What is a port number? Why is it important in networking?


**Answer:**

A port number is a 16-bit number used to identify specific processes or services running on a device. It's important for routing data to the correct application on a device.


**Question 7:**

Describe the role of the client and the server in a client-server model.


**Answer:**

In a client-server model, the client requests services or resources from the server, which processes the requests and provides the necessary data or services.


**Question 8:**

How does UDP handle data delivery in comparison to TCP? Give an example of a scenario where UDP might be preferred.


**Answer:**

UDP is connectionless and does not guarantee delivery or acknowledgment. It's preferred for scenarios where low latency is crucial, such as online gaming or streaming media, where occasional data loss is acceptable.


**Question 9:**

What is an IP address? How is it structured?


**Answer:**

An IP address is a numerical label assigned to each device connected to a network. It's structured as four sets of numbers separated by periods (e.g., 192.168.1.1), where each set represents an 8-bit binary number.


**Question 10:**

Explain the role of a socket in data communication between two devices.


**Answer:**

A socket serves as an endpoint for data communication. It provides a mechanism for applications to send and receive data over a network by specifying an IP address and port. Sockets facilitate the establishment of connections and data exchange between devices.

Network Programming Part I introduces fundamental concepts of computer networking and socket-based communication. In this course offered by Virtual University (VU), students delve into the essentials of creating networked applications, understanding protocols, and mastering the art of client-server interactions. This course serves as a stepping stone towards harnessing the power of networked systems. The curriculum begins with an exploration of networking basics, elucidating the architecture of the Internet, the role of protocols, and the significance of data transmission. Students decipher the layers of the OSI model, comprehending how each layer contributes to seamless communication between devices. The course progresses into the realm of sockets—a cornerstone of network programming. Through hands-on exercises and practical assignments, students learn to implement socket programming in various programming languages. They grasp the nuances of establishing socket connections, sending and receiving data streams, and error handling. Additionally, the course delves into the dichotomy of connection-oriented TCP (Transmission Control Protocol) and connectionless UDP (User Datagram Protocol), allowing students to discern their optimal usage scenarios. VU's Network Programming Part I delves deep into the mechanics of client-server interactions. Learners understand the dynamics of clients requesting services from servers and servers responding effectively. They unravel the intricacies of socket binding, listening, and accepting connections. Moreover, security considerations take the spotlight, emphasizing the importance of secure communication protocols and data integrity. DNS (Domain Name System) becomes a familiar term as students grasp its pivotal role in translating human-readable domain names into IP addresses, enabling efficient communication over the Internet. The course sheds light on IP addressing, subnetting, and the significance of ports in directing data to specific applications. As students progress, they gain insights into real-world applications of network programming. They explore scenarios where low-latency UDP trumps reliable TCP, such as multimedia streaming and online gaming. Assignments challenge learners to design and develop networked applications, applying their acquired knowledge to create functional and efficient systems. In conclusion, Network Programming Part I at VU serves as a comprehensive initiation into the realm of networked systems. Through a blend of theoretical understanding and practical implementation, students cultivate the skills necessary to embark on a journey of creating responsive, secure, and efficient networked applications. This course lays the foundation for advanced studies in network programming and equips students with a toolbox of skills indispensable in the digital landscape.