This script is designed to send multiple hex-encoded data packets to a TCP server over the same connection. It can optionally receive and print responses from the server.
- Sends multiple hex data packets over the same TCP connection.
- Optionally receives and prints responses from the server.
- Includes timeout handling for receiving responses.
- Automatically closes the socket after sending all packets.
- Open Google Colab.
- Copy and paste the Python code (provided below) into a new notebook.
- Replace the
ip
,port
, andhex_data_list
values in the code with your own. - Click on the "Run" button to execute the script.
If you'd prefer to use the pre-existing Colab notebook, you can click here to open the notebook. (Update this link with your Colab notebook URL once saved and shared).
- Save the script in a Python file (e.g.,
tcp_client.py
). - Open a terminal or command prompt.
- Navigate to the directory where you saved the script.
- Run the script using Python:
python tcp_client.py
For example:
ip = '192.168.1.100' # Replace with the server's IP address
port = 5005 # Replace with the server's port
hex_data_list = [
'78780D01086471700328358100093F040D0A',
'78781f121809030e1620c6027917540c4679500f142101cc00243c003e4a027fb7ac0d0a'
]
In case of issues with sending the message or generating the access token, appropriate error messages will be printed to the console, detailing the cause of failure.
This project is licensed under the MIT License. See the LICENSE file for details.