Skip to content

teodoradriann/News_Alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📰 News Alert

Author: Miron Teodor Adrian
Project: Real-time Message Redistribution System


📋 Overview

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.

🎯 Core Functionality

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

🏗️ Architectural Decisions

🔒 Reliable TCP Communication

  • send_all and recv_all Implementation
    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.

📡 Communication Protocol

  • 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

⚡ I/O Multiplexing

  • poll() Implementation: Enables efficient handling of multiple file descriptors simultaneously
  • Non-blocking Sockets: Ensures the server maintains its non-blocking nature

👥 Client Management System

Data Structures

  1. Socket-to-Client Mapping: sock_fd → client_data (IP, port, client_ID)
  2. Subscription Management: client_id → subscriptions

Connection Handling

  • ID Transmission: Performed after accept() via CONNECT packet
  • Reconnection Logic: Server differentiates between new clients and reconnections

🎯 Pattern Matching for Wildcards

Algorithm Overview

Two-Stack Approach:

  1. Client Subscription Stack: May contain wildcards (*, +)
  2. UDP Topic Stack: Contains the received topic

Matching Logic

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

✨ Implementation Features

🔧 Technical Highlights

  • 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

📊 Performance Characteristics

  • Non-blocking Operations: Ensures high throughput
  • Efficient Memory Management: Optimized data structures
  • Scalable Design: Supports multiple concurrent clients

🚀 Usage Scenario

News Alert enables the creation of a real-time notification system where:

  1. UDP Publishers send updates about various topics
  2. TCP Subscribers receive only relevant information based on their subscriptions
  3. Server acts as an intelligent message broker with pattern matching capabilities

🔗 Key Benefits

  • Real-time Communication
  • Topic-based Filtering
  • Wildcard Pattern Matching
  • Reliable Message Delivery
  • Scalable Architecture

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors