Network Programming Exam Guide
Network Programming Exam Guide
The accept() function is used by a server to accept incoming client connections on a listening socket. When a client attempts to connect, accept() completes the TCP handshake, creating and returning a new, fully connected TCP socket specifically for communication with the client. This separate socket allows the server to handle multiple clients by distinguishing communication channels .
Firewalls affect network programming by blocking unauthorized network traffic, which means that applications must be properly configured to communicate through firewalls. This includes defining rules that specify allowed traffic, potentially restricting application functionality or requiring modifications for compliance . For developers, this means considering firewall settings during application development to ensure seamless network communication and security.
The select() function allows a server to monitor multiple file descriptors to see if any have become ready for reading, writing, or if an error has occurred. This non-blocking approach enables the server to efficiently manage multiple connections by attending only to those ready for I/O operations, thus improving resource utilization and responsiveness in handling concurrent client requests .
The client-server model facilitates interactions by allowing web browsers (clients) to request specific services, such as web pages, from web servers (servers). The client initiates communication by sending a request for a webpage, and the server responds by providing the requested data . This architecture supports distributed computing by clearly delineating the roles of clients and servers.
Active sockets are used by clients to initiate connections, like a user's web browser connecting to a web server. Passive sockets, on the other hand, are used by servers to listen for incoming connections, such as a mail server waiting for clients to fetch emails. This distinction allows networked applications to manage different connection phases and roles, ensuring organized communication .
RPC plays a critical role by allowing programs to execute procedures on remote systems as if they were local, abstracting the complexity of network communication. This is achieved by using marshaling to format data for network transmission. By simplifying the interface and handling network details behind the scenes, RPC facilitates the development of distributed applications, enabling seamless integration of components located on different network nodes .
The TCP three-way handshake consists of three steps: 1) The client sends a SYN (synchronize) packet to initiate a connection to the server, 2) The server responds with a SYN-ACK (synchronize-acknowledge) to confirm receipt and willingness to establish a connection, and 3) The client sends an ACK (acknowledge) to the server, confirming the connection is established. This sequence ensures that both parties are ready to exchange data and establishes connection parameters .
TCP handles flow control using a mechanism called the sliding window protocol, where it adjusts the rate of data transmission based on the receiver's buffer capacity. This prevents data overflow at the receiver's end and ensures efficient use of network resources. By allowing the receiver to adjust the window size dynamically, TCP can adapt to changing network conditions, preventing congestion and maintaining data integrity .
Endianness affects how data is interpreted across systems with differing byte orders. Networking commonly uses big-endian order, whereas many architectures use little-endian. Conversion functions like htons() and ntohl() ensure data is correctly interpreted by converting it between the host byte order and network byte order, facilitating accurate and consistent communication between diverse systems .
TCP is a connection-oriented protocol ensuring reliable data transmission through acknowledgments and retransmissions. Applications like web browsers and email rely on TCP for its reliability. Conversely, UDP is connectionless, providing faster data transmission but without guarantees of delivery, making it suitable for applications like video streaming and online gaming where speed is prioritized over reliability .