Skip to content

agrawalx/connected-mailbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connected Mailbox

A simple, multi-threaded TCP message queue server written in Rust. This project demonstrates a basic implementation of a publish-retrieve message system using a shared in-memory queue.

Project Structure

The workspace consists of two main components:

  • tcp-server: The main application that runs a TCP server on 127.0.0.1:8080. It handles concurrent client connections and manages the shared message queue.
  • simpleDB: A library crate responsible for parsing commands (PUBLISH, RETRIEVE) and handling protocol logic.

Features

  • Multi-threaded Server: Handles multiple client connections simultaneously using std::thread.
  • In-Memory Queue: Messages are stored in a thread-safe Vec protected by a Mutex.
  • Simple Protocol: Text-based protocol for easy interaction.

Getting Started

Prerequisites

  • Rust (latest stable version)

Building the Project

To build the entire workspace:

cargo build

Running the Server

To start the TCP server:

cargo run -p tcp-server

The server will start listening on 127.0.0.1:8080.

Usage

You can interact with the server using tools like netcat (nc) or telnet.

Commands

  1. PUBLISH

    • Syntax: PUBLISH <message>
    • Description: Adds a message to the queue.
    • Example:
      PUBLISH Hello World
      
  2. RETRIEVE

    • Syntax: RETRIEVE
    • Description: Removes and returns the last message from the queue (LIFO).
    • Example:
      RETRIEVE
      

Example Session

Terminal 1 (Server):

cargo run -p tcp-server

Terminal 2 (Client):

$ nc localhost 8080
PUBLISH First Message
PUBLISH Second Message
RETRIEVE
Second Message/n
RETRIEVE
First Message/n

Development

To run the tests for the simpleDB library:

cargo test -p simple_db

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages