TCPListener is a simple TCP server that binds to a specified IP address and port. It listens for incoming TCP connections, receives data from clients, and processes it. The project consists of two Python scripts: main.py
to start the listener and listenport.py
to handle the TCP connection and data processing.
- main.py: The entry point of the application, responsible for initiating the TCP listener.
- listenport.py: Contains the logic for setting up the TCP server, accepting connections, and handling data received from clients.
- Listens on a specified IP address and port.
- Handles multiple client connections.
- Receives and processes incoming data.
- Automatically closes connections after data is received.
- Python 3
socket
library (for networking)select
library (for managing multiple connections)
-
Clone the repository:
- Clone this repository to your local machine.
-
Running the Script:
-
Start the TCP listener by running:
python main.py
-
The
main.py
script will start the listener on127.0.0.1
(localhost) by default.
-
-
Customizing IP and Port:
- You can customize the IP and Port by modifying the
main.py
script:LP.start(IP="your_ip_address", PORT=your_port_number)
- Replace
"your_ip_address"
andyour_port_number
with the desired IP and port.
- You can customize the IP and Port by modifying the
-
Start the TCP Listener:
- By default, the listener will start on
127.0.0.1:443
. - You can connect to it using any TCP client, send data, and observe the server processing the data.
- By default, the listener will start on
-
Data Reception and Processing:
- The listener will print out received data and wait for a semicolon (
;
) to indicate the end of the data stream. - Once all data is received, the connection will close.
- The listener will print out received data and wait for a semicolon (
- Add support for SSL/TLS to secure the connection.
- Implement logging for better debugging and monitoring.
- Allow configuration via command-line arguments instead of hardcoding IP and port.
If you have any questions or suggestions, feel free to contact the project maintainer at [email protected].