This is a basic Python UDP server that listens for incoming datagrams and prints messages received from clients. It runs a listener in a separate thread and allows the server operator to send messages via the console. The current implementation sends messages back to the server address (for demo/testing purposes), but can be extended to respond to actual client addresses.
- Uses UDP sockets (
socket.SOCK_DGRAM) - Listens for incoming messages in a separate thread
- Prints received messages from clients
- Allows sending messages from server console
- Clone or download the repo.
- Run the server script:
python server.py- Connect with a UDP client like
nc(netcat):
nc -u localhost 10000- Type messages in the client to send them to the server.
- Type messages in the server console to send messages (currently sent to
localhost:10000, can be modified to respond to clients).
- The server uses UDP, which is connectionless — there are no persistent client connections.
- Messages from clients are printed in the console along with their address.
- Currently, messages sent from the server go to its own address (
localhost:10000); you can update the code to store and respond to client addresses dynamically. - You can enhance the server by keeping a list of client addresses and sending replies back to them individually or broadcasting.