This project demonstrates a simple TCP server implementation in Python using the socket module. The server listens for incoming connections, sends a greeting message to the client, and then closes the connection.
- Python3
- Kali Linux
- Visual Studio Code
-
TCP Socket: Creates a TCP/IP socket using socket.AF_INET and socket.SOCK_STREAM.
-
Server Binding: Binds the server to the host and port.
-
Connection Handling: Listens for incoming connections and accepts them.
-
Message Sending: Sends a greeting message to the connected client.
-
Connection Management: Closes the client connection after sending the message.
-
Establishes a TCP connection to a specified server and port.
-
Receives data from the server.
-
Closes the connection after receiving the message.
-
Prints the received message in ASCII format.
- Create a TCP Socket: Uses socket.AF_INET and socket.SOCK_STREAM to create a TCP/IP socket.
- Bind to Host and Port: Binds the socket to the host (hostname) and a port (444).
- Listen for Connections: Listens for up to 3 incoming connections.
- Accept Connections: Accepts incoming client connections and prints the client's address.
- Send Message: Sends a greeting message to the client.
- Close Connection: Closes the client socket after sending the message.
To run the server:
-
Execute the script: python server.py
-
The server will start listening for incoming connections on port 444 and will send a greeting message to each connected client.
- Python 3.x
- No additional dependencies