This project implements a system for calculating the weight of strings through socket communication, efficiently managing data transfer between a client and a server to enable dynamic calculations based on the transmitted strings
- Socket Communication: Establishes a reliable connection between the client and server for data transfer.
- String Weighting Calculation: Computes the weight of strings based on predefined criteria.
- Configurable Parameters: Allows users to adjust parameters for string weighting calculations.
- Memory Optimization: This project is optimized to minimize memory consumption, allowing for operation with a high data throughput without critically affecting dynamic memory
- Python: 3.10.10 (Libraries built-in)
git clone https://github.com/acevedoesteban999/String-Weighting-through-Socket-Communication
Enter the cloned folder 'String-Weighting-through-Socket-Communication' and create the file named .env with
HOST = localhost
PORT = 8080
MAX_LINES_TO_SEND = 100
GENERATE_MAX_LINES = 1000
READ_WRITE_MAX_LINES = 1000
FILE_STRINGS = chains.txt
FILE_RESPONSE = response.txt
In a terminal, type:
python server.py
It should look something like: 'Server has started on localhost:8080'
In a different terminal than the server, type:
python client.py
It should look something like
How many strings the file will contain?
* Only integers are supported
* Minimum 1 string
* Maximum 1 000 000 strings
Wait for the process to finish and see something like:
Process completed in [0.003992795944213867] seconds
When you reach this point, you will have two files: one with the generated strings and another with their weights
- The server only starts if a socket connection to the server is established, to avoid unnecessary work on the files
- The parameters MAX_LINES_TO_SEND and READ_WRITE_MAX_LINES are responsible for optimizing memory usage against speed
- Since the maximum is 1 million possible lines, and each line has a maximum of 100 characters, this amounts to 100 million bytes, or 100 MB. To avoid this large memory usage, both in the generation of the strings, writing, reading, and transmission, it is divided into portions and will be processed cyclically to optimize the use of dynamic memory.