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.