Code Monkey home page Code Monkey logo

socket_demo's Introduction

This project has been developed with:

  • ruff for linter, and formatter,
  • mypy for type checking,
  • pytest for unit-test,
  • poetry for package manager

code lives in mathserver package.

Getting started

You need poetry to setup the project.

For nix user a nix file is provided which install poetry and set FHS env for ruff. Just run nix-shell from the project root

Install the project:

poetry install

Then, you can run server with:

poetry run server

The server will listen, by default, on localhost:9999. But this can be overloaded with SERVER_LISTEN_ADDRESS and SERVER_PORT environment variables.

The client can be runned with:

$ poetry run client --help
usage: Arithmetic client [-h] [--burst BURST] host port input_file output_file

A client for the arithmetic server

positional arguments:
  host
  port
  input_file
  output_file

options:
  -h, --help     show this help message and exit
  --burst BURST  how many concurrent query you want

By example if the server is listening on localhost:9000 one can run:

poetry run client localhost 9999 operations.txt result.txt

The script will read operations from operations.txt and write their results in result.txt.

The burst option (which default to 1) allows you to open several sockets at the same time, enabling you to carry out several requests simultaneously on the server while maintaining the order of operations. A reasonable number can divide execution time by 2. Of course, this depends on a number of factors, such as the number of core on the server and client, and the number of sockets authorized by the system.

Develop

run the test:

pytest

check code:

ruff check

format code:

ruff format

type checking:

mypy .

Todo

requirements

  • Develop a client which is able to send the information given at operations.7z:
    • send the information using sockets to the service,
    • receive information through the sockets and store the results in a file,
  • Develop a service in Python which is built with the following features:
    • receive information using sockets,
    • It is built by 2 different processes (at least). Consider having more processes to speed calculations,
    • Processes must be able to exchange information using pipes. Please DO NOT use Threading or Pool,
    • Parent process must create and destroy child process for the arithmetic operations given at operations.7z,
    • Once the arithmetic operation is finished on the second process, such process should be destroyed by the parent process,
    • Consider that operations should not be calculated using eval(),
    • Consider using logging instead of console prints.
  • parser

socket_demo's People

Contributors

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