Yucheng0208 / UDP-Socket

Socket Communication Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UDP Socket Communication Example

This is a simple client-server UDP socket communication example in Python. It demonstrates communication between a client and a server using User Datagram Protocol (UDP).

Getting Started

Prerequisites

Make sure you have Python installed on your system.

Installation

  1. Clone the repository:

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

    cd udp-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 sends a message to the server and receives a response.

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

  4. The communication continues until you decide to exit.

Code Explanation

  • server.py: Contains the server-side code for binding to an address and handling UDP communication.

  • client.py: Contains the client-side code for sending a message to the server and receiving the response.

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 localhost --port 2000

# Example client customization
python client.py --host localhost --port 2000

License

This project is licensed under the MIT License - see the LICENSE file for details.


Replace "Youcheng208" in the repository URL, update the file names if needed, and ensure to customize the host and port settings in the examples accordingly.

About

Socket Communication Example

License:MIT License


Languages

Language:Python 100.0%