1. INFORMATION SCIENCE AND TECHNOLOGY
Computer Networking
Topic : An example of socket programming :
An internet file server
Subject Faculty :
Asst Professor
Mrs Pradeepa J
Topic By :
Anubhav S
1KT21IS004
2. Socket Programming
Socket programming is a fundamental technique for
enabling communication between applications on a
network.
It provides a way for programs to establish connections,
exchange data, and coordinate actions, regardless of their
physical locations
Each socket has a unique address (IP address and port
number) that identifies it.
Applications can "plug into" sockets to create
connections and start sending and receiving data.
3. Server Setup
This consists of a basic Internet file server and client. The server serves files
to clients, while the client requests and receives files from the server.
The server and client code are designed to be platform-independent, meaning
they can be compiled and executed on any UNIX system connected to the
Internet.
Port Selection
Ports are numerical identifiers used to distinguish between different network
services running on the same host.
The server code selects a port number (e.g., 12345) for communication. It's
essential to choose a port within the range of 1024 to 65535 to avoid conflicts
with other processes.
Ports below 1024 are typically reserved for privileged users or standard
services.
4. Constants Definition:
The server code defines constants for the chunk size and maximum pending
connections.
The chunk size determines the size of data packets transmitted during file transfer,
impacting the efficiency of data transmission.
Chunk Size and Efficiency:
The chunk size influences the efficiency of file transfer by determining the size of
data packets transmitted over the network.
Choosing an appropriate chunk size helps optimize network utilization and minimize
overhead associated with data transmission.
5. Handling Pending Connections:
The specified maximum number of pending connections determines how many
clients can wait in the queue before additional connections are rejected.
Effective management of pending connections helps prevent server overload
and ensures optimal performance.
Output Handling:
The fetched file is written to standard output on the client side, allowing it to
be displayed in the console or redirected to a file or pipe.
This basic mechanism for output handling provides a simple yet effective way
to retrieve and view file content on the client side.