This is a simple client-server socket communication example in Python. It demonstrates communication between a client and a server using TCP/IP sockets.
Make sure you have Python installed on your system.
-
Clone the repository:
git clone https://github.com/your-username/socket-communication-example.git
-
Navigate to the project directory:
cd socket-communication-example
-
Run the server:
python server.py
-
Run the client in a separate terminal or script:
python client.py
-
Run the server script to start the server listening on a specified host and port.
-
Run the client script, which connects to the server and allows you to send and receive messages.
-
Enter a string on the client side, and it will be sent to the server. The server responds with a message.
-
The communication continues until you decide to exit.
-
server.py
: Contains the server-side code for accepting connections and handling communication. -
client.py
: Contains the client-side code for connecting to the server and interacting with it.
You can customize the host and port settings in both server.py
and client.py
according to your requirements.
# Example server customization
python server.py --host 0.0.0.0 --port 2000
# Example client customization
python client.py --host 127.0.0.1 --port 2000
This project is licensed under the MIT License - see the LICENSE file for details.
Make sure to replace "Yucheng0208" in the repository URL and update the file names if needed. Additionally, provide information about how to customize the host and port settings for both the server and the client.