Skip to content

Yucheng0208/TCP-Socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Socket Communication Example

This is a simple client-server socket communication example in Python. It demonstrates communication between a client and a server using TCP/IP sockets.

Getting Started

Prerequisites

Make sure you have Python installed on your system.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/socket-communication-example.git
  2. Navigate to the project directory:

    cd socket-communication-example
  3. Run the server:

    python server.py
  4. Run the client in a separate terminal or script:

    python client.py

Usage

  1. Run the server script to start the server listening on a specified host and port.

  2. Run the client script, which connects to the server and allows you to send and receive messages.

  3. Enter a string on the client side, and it will be sent to the server. The server responds with a message.

  4. The communication continues until you decide to exit.

Code Explanation

  • 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.

Customization

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

License

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.

About

Socket Communication Example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages