Git Product home page Git Product logo

eddiegulay / echosocket Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 557 KB

This is an experiment on quicker ways to improve inference time when transfering data from client to server

Home Page: https://echosocket.my.canva.site/echosocket

License: MIT License

Python 99.91% Batchfile 0.09%
client communication echo master python realtime reverse-shell server slave socket tanzania echo-socket

echosocket's Introduction

EchoSocket

This is EchoSocket, a project that facilitates two-way communication between a server and multiple clients. All in the look for faster realtime server-client communication.

EchoSocket

Table of Contents

Features

  1. Simple Two-Way Communication:

    • Enables real-time communication between a master server and multiple clients.
    • Clients can send and receive messages seamlessly, fostering efficient interactions.
  2. Modular Task Execution:

    • Register custom task functions on the server for dynamic execution.
    • Clients submit tasks, and the server executes corresponding functions, allowing for easy extensibility.
  3. Graceful Server Shutdown:

    • Ensures a controlled termination process upon server shutdown requests.
    • Closes client connections gracefully, maintaining stability in the system.

Getting Started

Prerequisites

  • Python (version 3.x recommended)
  • Git (optional)

Installation

  1. Clone the repository:

    git clone https://github.com/eddiegulay/EchoSocket.git

    or download and extract the ZIP file.

  2. Navigate to the project directory:

    cd EchoSocket
  3. Install dependencies (if any):

    # we use sockets for this project. it's a built-in module, so no need to install anything!

Usage

Project Structure

EchoSocket/
|-- basic/
|   |-- client.py
|   |-- server.py
|   |-- multi_clients.py
|   |-- single_action.py
|-- master.py
|-- slave.py
|-- src/
|   |-- client.py
|   |-- server.py
|-- |-- jobs.py
|-- assets/
|   |-- echoSocket.jpg
|-- LICENSE
|-- .gitignore
|-- README.md
|-- *_server.py*
|-- *_client.py*
  • basic: Contains basic client and server scripts.
  • src: Contains server and client classes plus server jobs (The actual project)
  • _server.py: Where the server script is located.
  • _client.py: Where the client script is located.

Using EchoSocket

Server Setup

  1. Create Server Instance:

    In your _server.py file, create an instance of the server and define your custom task functions.

    # _server.py
    from src.server import Server
    from src.jobs import reverse_string_task
    
    
    if __name__ == "__main__":
        # Create a server instance
        master = Server("127.0.0.1", 8080, "Master")
    
        # Register task functions
        master.register_task_function('reverse', reverse_string_task)
    
       # you can register as many functions as you can
    
        # Run the server
        master.run()
  2. Run the Master Server:

    Execute the _server.py script to start the master server.

    python _server.py

Client Interaction

  1. Start a Slave Client:

    In your _client.py file, create an instance of the client and send a task.

    # _client.py
    from src.client import Client
    
    if __name__ == "__main__":
        # Create a client instance
        client = Client("127.0.0.1", 8080, "The Client")
    
        # Send a task to reverse a string
        client.send_task('reverse', 'Hello, EchoSocket!')
    
        # Wait for the response from the server
        response = client.client_socket.recv(1024).decode('utf-8')
        print(f"Reversed Output: {response}")
    
        # Close the client connection
        client.close_client()
  2. Run the Client:

    Execute the _client.py script to start the slave client.

    python _client.py

echosocket's People

Contributors

eddiegulay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  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.