LU7 Socket Programming Flashcards
What is the primary purpose of socket programming?
To enable IPC, especially across a network in a distributed system
In a networked environment, what architectural model is commonly used with sockets?
Client-server model
Briefly describe the role of the ‘client’ in a client-server socket communication.
Initiates a connection to the server and requests services.
Describe the role of the ‘server’ in the client-server model.
Listens for incoming connections, accepts requests, and provides services.
What’s the purpose of fork()
?
Creating child process.
How do processes communicate between parent and child after a fork()
?
[ SPMs ]
Using IPC mechanisms:
- signal
- pipes
- message queues
- shared memory
In a networked program using sockets, what medium enables communication between client and server?
A network (e.g., LAN, WAN).
What defines the rules for communication between sockets?
Protocols (e.g., TCP/IP).
What are sockets?
The traditional UNIX IPC mechanism that allows processes to communicate, even if they’re on different machines.
Name a few common uses of sockets?
transferring data/video/voice/files from one machine to another
Name two types of connections.
Connection-oriented, Connectionless
Connection-oriented communication (like TCP) establishes a dedicated, reliable connection with ordered delivery.
Connectionless communication (like UDP) sends data independently without guarantees of order or delivery.
What are the key characteristics of Connection oriented model?
- dedicated connection
- reliable packet transfer
- packet will send and receive in order
What are the key characteristics of Connectionless oriented model?
- Data packets routed individually
- No guarantee of delivery, order, or data integrity, speed prioritized
Name a common protocol used for connection oriented model.
TCP/IP
Transmission Control Protocol/Internet Protocol
Name a common protocol used for connectionless oriented model.
UDP
user datagram protocol
What is the disadvantage of Connection oriented model?
Requires more overhead due to the setup phase, slower compared to connectionless model
What is the disadvantage of Connectionless oriented model?
Data packets may arrive out of order or be lost, less reliable than connection-oriented communication.
To establish any communication, client and server need to be connected at what level?
Hardware & Software level
What are the few steps in a server?
[ CNSAS ]
- creating a server socket
- naming a server socket
- set the maximum number of pending connections
- accepting connections
- serving a client
What are the few steps in a client?
1 creating a client socket
2. connecting a client socket to the server socket
3. communicating via sockets
What is the format of IP address?
4 decimal numbers separated by dot
How UNIX system calls deal with IP address to be usable for later?
convert using inet_addr()
What is a socket?
An interface between application and network
What does the socket type dictates?
style of communication (reliable or best effort, connection-oriented or connectionless)