Author: Miron Teodor Adrian
Project: Real-time Message Redistribution System
News Alert is a server application that acts as a message redistribution system between UDP and TCP clients. The server simultaneously handles UDP and TCP connections, enabling TCP users to subscribe to specific topics and receive filtered messages from UDP publishers.
| Client Type | Role | Description |
|---|---|---|
| UDP Clients | Publishers | Send messages with specific topics to the server |
| TCP Clients | Subscribers | Connect to server and subscribe to topics of interest |
| Server | Message Broker | Filters and redistributes messages based on subscriptions |
send_allandrecv_allImplementation
Since TCP doesn't guarantee complete data transmission in a single operation, the application uses buffering to ensure all data is properly sent and received.
- TCP Packet Structure: Contains operation type and transmitted data
- Message Types:
OK,CONNECT,ERROR,NEWS, etc. - Standardized Communication: Server-client interaction through well-defined message types
poll()Implementation: Enables efficient handling of multiple file descriptors simultaneously- Non-blocking Sockets: Ensures the server maintains its non-blocking nature
- Socket-to-Client Mapping:
sock_fd → client_data(IP, port, client_ID) - Subscription Management:
client_id → subscriptions
- ID Transmission: Performed after
accept()via CONNECT packet - Reconnection Logic: Server differentiates between new clients and reconnections
Two-Stack Approach:
- Client Subscription Stack: May contain wildcards (
*,+) - UDP Topic Stack: Contains the received topic
| Wildcard | Behavior |
|---|---|
| Equal Heads | pop() both stacks |
* (Multi-level) |
pop() subscription, then pop() topic until match |
+ (Single-level) |
pop() topic stack once |
| No Match | Continue to next subscription |
- Comprehensive Logging: Debug sequences for detailed monitoring
- Modular Architecture: Scalable and maintainable codebase
- Connection Resilience: Robust handling of connections and reconnections
- Advanced Matching: Sophisticated wildcard pattern matching
- Non-blocking Operations: Ensures high throughput
- Efficient Memory Management: Optimized data structures
- Scalable Design: Supports multiple concurrent clients
News Alert enables the creation of a real-time notification system where:
- UDP Publishers send updates about various topics
- TCP Subscribers receive only relevant information based on their subscriptions
- Server acts as an intelligent message broker with pattern matching capabilities
- ✅ Real-time Communication
- ✅ Topic-based Filtering
- ✅ Wildcard Pattern Matching
- ✅ Reliable Message Delivery
- ✅ Scalable Architecture