Skip to content

conoregann/FoodMarketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Systems

Electronic Food Marketplace Simulator

Author: Conor Egan


1. Project Overview

This project is a Java-based simulation of an electronic food marketplace. It uses a multithreaded client-server architecture built with TCP sockets to allow multiple buyers to connect concurrently to a single seller and purchase items.

The system features:

  • A thread-per-connection model on the server.
  • Synchronized, atomic access to shared resources (market inventory) to prevent race conditions.
  • A broadcast mechanism to notify all connected clients of market updates in real-time.

2. Directory Structure

The project is organized using a standard Java package structure:

  • FoodMarketplace/
    • src/
      • marketplace/
        • SellerServer.java
        • BuyerHandler.java
        • Marketplace.java
        • BuyerClient.java
        • ServerListener.java
        • Config.java
    • marketplace/
    • config.properties
    • README.md
    • .gitignore

3. Compilation and Execution Instructions

Prerequisites

  • Java Development Kit (JDK) 11 or later.

Step 1: Compile the Code

Open a terminal in the root FoodMarketplace directory and run the following command to compile all source files:

javac -d . src/marketplace/*.java

This will create a marketplace directory in the root containing the compiled .class files.

Step 2: Run the Seller Server

In a new terminal, from the root FoodMarketplace directory, start the server:

java -cp . marketplace.SellerServer

The server will start and begin listening for client connections on the port specified in config.properties.

Step 3: Run the Buyer Clients

For each buyer you wish to simulate, open a new, separate terminal. From the root FoodMarketplace directory, run the following command:

java -cp . marketplace.BuyerClient

A new client will connect to the server. You can now interact with the marketplace using the following commands in the client terminal:

  • list: Shows the currently available item and stock.
  • buy : Attempts to buy the specified quantity of the current item (e.g., buy 2).
  • quit: Disconnects from the server.

About

Distributed Systems | Multithreaded Client-Server Architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages