High-Performance HTTP/HTTPS Server with WebSocket Support
The Carbon web server is installed and running successfully. This is the default page that is displayed when the server is working correctly.
Carbon is a high-performance, production-ready HTTP/HTTPS server written in C for Linux systems. It features modern web technologies including WebSocket support, SSL/TLS encryption, and comprehensive security measures.
Epoll-based async I/O, zero-copy file transfers, and thread pooling
SSL/TLS support, rate limiting, security headers, and input sanitization
Full RFC 6455 compliant WebSocket implementation for real-time apps
Simple Linux-style configuration file with comments
The server is configured through the server.conf file located in the server root directory.
# Carbon Web Server Configuration File
# Server listening port
port = 8080
# Enable HTTPS (requires valid certificates in certs/ directory)
use_https = false
# Log file location
log_file = log/server.log
# Maximum number of worker threads
max_threads = 4
# Server name or IP address
server_name = localhost
# Enable verbose logging
verbose = true
# Enable WebSocket support
enable_websocket = true
To enable HTTPS support, you'll need SSL certificates. You can use self-signed certificates for testing or obtain certificates from Let's Encrypt for production.
# Create certificates directory
mkdir -p certs
# Generate self-signed certificate
openssl req -x509 -newkey rsa:4096 -nodes \
-keyout certs/key.pem \
-out certs/cert.pem \
-days 365 \
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
# Edit server.conf
use_https = true
Carbon includes full WebSocket support (RFC 6455 compliant) for building real-time applications.
Use the built-in test client:
# Browser
http://localhost:8080/websocket-test.html
# Command line (requires wscat: npm install -g wscat)
wscat -c ws://localhost:8080
# Secure WebSocket (if HTTPS enabled)
wscat -c wss://localhost:443
// Connect to WebSocket server
const ws = new WebSocket('ws://localhost:8080');
// Connection opened
ws.addEventListener('open', (event) => {
console.log('Connected!');
ws.send('Hello Server!');
});
// Listen for messages
ws.addEventListener('message', (event) => {
console.log('Received:', event.data);
});
Understanding the server directory layout:
www/ - Web root directory (place your HTML, CSS, JS files here)certs/ - SSL certificate files (cert.pem, key.pem)log/ - Server log filesserver.conf - Main configuration fileserver - Server executable./server
# Press Ctrl+C in the server terminal
# Or send SIGTERM signal
kill -TERM $(pgrep -f './server')
tail -f log/server.log
curl http://localhost:8080
make clean && make
If you see "Address already in use" errors:
# Find process using port 8080
sudo lsof -i :8080
# Or
sudo netstat -tulpn | grep 8080
# Kill the process
kill -9 <PID>
Ports below 1024 require root privileges:
# Option 1: Run as root (not recommended for production)
sudo ./server
# Option 2: Use setcap to grant capability
sudo setcap 'cap_net_bind_service=+ep' ./server
./server
enable_websocket = true in server.confws:// for HTTP and wss:// for HTTPS