Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Network Programming

Four network servers written from scratch in C++ over BSD sockets, progressing from a single-client remote shell to a concurrent multi-user server, an HTTP/CGI server, and a SOCKS4 proxy.

Projects

1-npshell/ — remote shell with pipes

A shell (npshell.cpp, 363 lines) supporting ordinary pipes, numbered pipes (|N / !N — pipe output to a command N lines later), and file redirection, executing external commands via fork/exec with correct pipe plumbing between children.

2-concurrent-servers/ — three concurrency models

The same multi-user "remote working station" server implemented three ways, to compare concurrency architectures:

  • np_simple — one process per connection (fork per client)
  • np_single_proc (762 lines) — single process, all clients multiplexed with select()
  • np_multi_proc (725 lines) — process per client with shared memory + FIFOs for cross-user pipes and broadcast messaging

3-http-cgi-server/ — HTTP server + CGI

An HTTP server (http_server.cpp) that parses requests and dispatches to CGI programs, plus a CGI console (cgi_server.cpp, 387 lines) built on Boost.Asio that opens multiple concurrent SSH-like sessions and streams their output into an HTML panel. Includes a minimal Boost.Asio echo-server example.

4-socks4-proxy/ — SOCKS4/4A proxy with firewall

A SOCKS4 proxy (socks_server.cpp, 353 lines) supporting both CONNECT and BIND modes, with a configurable firewall (socks.conf) that permits/denies connections by operation and destination.

Concepts demonstrated

BSD sockets, fork/exec process management, select() multiplexing, inter-process communication (shared memory, FIFOs, pipes), HTTP and CGI, the SOCKS4 protocol, and Boost.Asio's asynchronous model — the core toolkit of concurrent network back ends.

Build

Each project has its own Makefile:

cd 2-concurrent-servers && make
./np_single_proc 8000        # then telnet/nc to localhost 8000

Context

Coursework for Network Programming at NYCU (Spring 2024), taught by Prof. I-Chen Wu. Each project directory is my own implementation against the course specification; the shell command binaries (noop, number, removetag) are small provided test utilities. Cleaned up (compiled binaries, course spec PDFs, and editor configs removed) and documented for release.

About

Four network servers in C++ from scratch: piped remote shell, concurrent multi-user server (select / shared memory), HTTP+CGI, and a SOCKS4 proxy

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages