A high-performance C-based server that combines HTTP web serving and real-time chat in a single application. Built with advanced networking concepts including event-driven architecture, connection pooling, and intelligent protocol detection.
Just want to try it? Run this:
./run.shWant to see the chat demo? Run this:
./demo.shThat's it! ๐
- Static file serving - Host websites, images, CSS, JavaScript
- Smart routing - Automatic index.html serving
- File browsing - Directory listings when enabled
- Multi-format support - HTML, CSS, JS, images, text files
- Persistent chat sessions - Stay connected, no reconnection needed
- Multiple chat rooms - Create and join different rooms
- User management - Nicknames, user lists, join/leave notifications
- Rich commands - All commands working:
/help,/join,/nick,/list,/quitand more - Live messaging - Real-time chat with other users via telnet
- Command processing - Fixed newline handling for all terminal clients
- Dual-protocol - HTTP (port 8080) + Chat (port 8081) simultaneously
- Event-driven - Handles 1000+ concurrent connections efficiently
- Smart detection - Automatically routes HTTP vs Chat traffic
- Configurable - Easy INI-style configuration
- Production logging - Multi-level logs with colors
./run.sh
# Then visit: http://localhost:8080./run.sh
# In another terminal, connect via telnet:
telnet localhost 8081
# Then try these commands:
/help
/join lobby
/nick YourName
Hello everyone!
/quit# Terminal 1 - Start the server:
./run.sh
# Terminal 2 - First user:
telnet localhost 8081
/join lobby
/nick Alice
Hello everyone!
# Terminal 3 - Second user:
telnet localhost 8081
/join lobby
/nick Bob
Hi Alice!
# Now they can chat in real-time!Note: All chat commands are now working properly via telnet! The /help command will show you all available options.
Connect via telnet localhost 8081 and use these commands:
| Command | Description | Example |
|---|---|---|
/help |
โ Show all commands | /help |
/join <room> |
โ Join or create a room | /join lobby |
/nick <name> |
โ Change your nickname | /nick Alice |
/list users |
โ See who's in your room | /list users |
/list rooms |
โ See available rooms | /list rooms |
/leave |
โ Leave current room | /leave |
/clear |
โ Clear the screen | /clear |
/quit |
โ Exit chat | /quit |
<message> |
โ Send chat message | Hello world! |
All commands are working properly! Connect with multiple telnet sessions to test real-time chat.
- Linux/WSL (Ubuntu, Debian, etc.)
- GCC compiler (
sudo apt install build-essential) - Make (usually included with build-essential)
# Clone or download the project
cd multiserver
# Build (first time only)
make
# Run the server
./run.sh
# Stop the server (if needed)
./stop.sh
# Or run manually
./multiserver -c config/test.conf- Port already in use? - The run script automatically stops existing servers
- Permission denied? - Make scripts executable:
chmod +x *.sh - Build errors? - Install build tools:
sudo apt install build-essential
multiserver/
โโโ run.sh # Quick start script
โโโ demo.sh # Interactive chat demo
โโโ stop.sh # Stop server script
โโโ multiserver # Main executable (after build)
โโโ Makefile # Build configuration
โโโ config/ # Server configuration
โ โโโ test.conf # Default config file
โโโ src/ # Source code
โ โโโ main.c # Program entry point
โ โโโ server.c # Core server engine
โ โโโ connection.c # Connection management
โ โโโ enhanced_chat.c # Chat system
โ โโโ logging.c # Logging system
โโโ include/ # Header files
โโโ www/ # Web content directory
โ โโโ index.html # Default web page
โโโ tools/ # Demo and testing tools
Edit config/test.conf to customize:
[server]
http_port = 8080 # Web server port
chat_port = 8081 # Chat server port
max_connections = 1000 # Concurrent connection limit
[logging]
level = INFO # DEBUG, INFO, WARN, ERROR
console = true # Show logs in terminal
to_file = true # Save logs to file
[chat]
max_rooms = 100 # Maximum chat rooms
max_users_per_room = 50 # Users per room limit- Event-Driven: Uses
select()for non-blocking I/O - Protocol Detection: Automatically distinguishes HTTP vs Chat traffic
- Connection Pooling: Efficient memory and resource management
- Persistent Sessions: Chat connections stay alive for real-time messaging
- Modular Design: Clean separation between HTTP, Chat, and Core systems
- 1000+ concurrent connections supported
- Non-blocking I/O for maximum efficiency
- Memory-safe connection management
- Signal handling for graceful shutdown
- Dual-port operation (HTTP + Chat simultaneously)
- Protocol multiplexing on single server
- Keep-alive connections for chat persistence
- Automatic cleanup of idle connections
- Clean C code with comprehensive error handling
- Configurable logging with multiple levels
- Easy build system with Make
- Cross-platform (Linux/Unix/WSL)
This server demonstrates core networking concepts and is ready for extension:
- Authentication system - User login/registration
- File upload handling - POST request processing
- Database integration - Persistent chat history
- WebSocket support - Browser-based chat client
- Load balancing - Multiple server instances
- SSL/TLS encryption - Secure connections
โ
Fully Functional - Both HTTP and Chat working perfectly
โ
All Commands Working - /help, /join, /quit, etc. all functional via telnet
โ
Production Ready - Handles multiple users simultaneously
โ
Fixed Command Processing - Proper newline handling for all terminal clients
โ
Real-Time Chat - Multiple users can chat simultaneously
โ
Well Documented - Clear code and extensive comments
โ
Easy to Use - Simple scripts for immediate testing
โ
Extensible - Clean architecture for future features
Ready to showcase networking skills with working chat demo! ๐