This repository contains six assignments developed for the NES 416 – Network Programming course at JUST (Jordan University of Science and Technology).
The assignments cover TCP/UDP socket programming, client-server models, I/O multiplexing, and multithreading in the C programming language.
- Understand the fundamentals of network programming in C.
- Build TCP and UDP client-server applications.
- Implement iterative and concurrent servers.
- Apply signal handling in UNIX/Linux.
- Use I/O multiplexing for scalable client-server interaction.
- Develop multi-threaded applications for parallel processing.
- Practice file transfer, authentication, and string processing over sockets.
- Language: C
- Compiler: GCC (GNU Compiler Collection)
- Libraries:
<stdio.h>,<stdlib.h>,<string.h><unistd.h>,<pthread.h><sys/socket.h>,<netinet/in.h>,<arpa/inet.h>
- Environment: UNIX/Linux
| # | Assignment | Key Focus | Description |
|---|---|---|---|
| 1 | Basic Client Interaction | TCP Basics | Simple client sends name to server → server replies with name + timestamp. |
| 2 | Iterative TCP Password Verification | TCP, Iterative Server | Client submits password → server validates against security rules. Connection open until done. |
| 3 | Concurrent TCP Server with Signals | Concurrency, Signals | Server forks a child per client, handles multiple requests, client exits on SIGQUIT. |
| 4 | UDP File Download Service | UDP, File Transfer | Client authenticates with server, requests file list, downloads files in chunks, adjusts buffer sizes. |
| 5 | TCP/UDP with I/O Multiplexing | Hybrid, Multiplexing | Client menu: (1) UDP download, (2) TCP upload, (3) Quit. Uses I/O multiplexing for efficiency. |
| 6 | Multithreaded TCP Character Counting | TCP, Threads | Multi-threaded client/server → counts occurrences of specific characters in strings. |
- Goal: Learn the building blocks of a network application.
- Task: Client sends a name to the server, server replies with name + current time/date.
- Command Example:
hw1 <server_ip> <name>
- Goal: Implement TCP client-server with iterative design.
- Client: Sends password to server until user types done.
- Server: Validates password (length 8–16, includes 3 of: uppercase, lowercase, number, special).
- Key Concepts: Iterative server, TCP communication.
- Goal: Understand concurrency + signals in client-server systems.
- Server: Forks child per client, prints client IP/port, handles multiple requests.
- Client: Exits on SIGQUIT, not by done.
- Extra Rule: Special characters allowed @#$^&*+= (except %).
- Goal:
Practice using UDP sockets to implement a simple file transfer system. - Process:
- Client authenticates with handshake bytes (
0x55,0xAA). - Server responds with a list of available files.
- Client selects a file to download.
- File is transferred in 1024-byte chunks.
- Client can type
doneto exit the session. - (Extra Feature): Client adjusts and displays send/receive buffer sizes for performance testing.
- Client authenticates with handshake bytes (
- Goal: Investigate TCP + UDP with I/O multiplexing.
- Client Menu:
- Download file via UDP.
- Upload file via TCP (to concurrent server).
- Quit.
- Features:
- Hostname resolution via /etc/hosts.
- Upload/download over different protocols.
- Prevents flooding server (UDP call limited to once per 5 sec).
- Goal: Combine multithreading with TCP sockets.
- Client:
- Input string + characters to count.
- Creates one thread per character to send request to server.
- Server:
- Multi-threaded, counts occurrences, reports back per client thread.
- Tracks number of threads created so far.
- Output Example:
T2: # of r’s in the string = 1 T3: # of A’s in the string = 3 T4: # of 1’s in the string = 2 Total occurrences = 6
