Giter Site home page Giter Site logo

java_players_communication's Introduction

Player Communication Project

This project demonstrates a simple communication system between two players using Java sockets. The project includes two main scenarios:

  • Running both players in the same Java process.
  • Running each player in separate Java processes.

Project Structure:

Java Project/
├── src/
│ └── player_communication/
│ ├── Player.java
│ ├── Player1.java
│ ├── Player2.java
│ └── Main.java
├── out/
├── run_same_process.bat
├── run_separate_processes.bat
└── README.md

Prerequisites:

  • Java Development Kit (JDK) installed
  • Windows OS

Detailed Explanation:

Player.java
This class handles the communication logic for each player.

Player1.java
This class initializes Player1 with specific parameters and starts its execution.

Player2.java
This class initializes Player2 with specific parameters and starts its execution.

Main.java
This class is used to run both Player1 and Player2 in the same Java process using separate threads.

run_same_process.bat
This batch script is used to compile the Java classes and run both Player1 and Player2 in the same Java process.

run_separate_processes.bat
This batch script is used to compile the Java classes and run Player1 and Player2 in separate command prompt windows.

Notes:

  • Ensure that the ports (5001 and 5002) used by the players are not in use by other applications to avoid java.net.BindException: Address already in use errors.
  • If you encounter issues with ports being in use, you may need to free the ports by stopping any applications that are using them.

How to Run the Project

Running Both Players in the Same Java Process

  1. Open a terminal or command prompt.
  2. Navigate to the project directory.
  3. Compile the Java files and run the main class using the batch script:
    run_same_process.bat
    

Output:

image desc

Running Each Player in Separate Java Processes

  1. Open a terminal or command prompt.
  2. Navigate to the project directory.
  3. Compile the Java files and run the players in separate command prompt windows using the batch script:

run_separate_processes.bat

Output:

image desc

java_players_communication's People

Contributors

waleedahmed0001 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.