Introduction and example usage of echo Server in python
This article mainly explains "the introduction and example usage of echo server in python". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the introduction and example usage of echo server in python".
1. Echo server is a very useful tool for debugging and testing.
2. The function of the protocol is simple, which is to receive and send as is.
3. Implement echo server so that client.py can receive user input cyclically.
It is sent to the server, and after receiving the message, the server returns the message as is to client.
Example
From socket import * # Import module udpSock = socket (AF_INET,SOCK_DGRAM) udpSock.bind ((", 8888)) # bind a port while True:# to keep sending and receiving recvData = udpSock.recvfrom (1024) # first receive the sent data udpSock.sendto (recvData [0], recvData [1]) # send the data back to udpSock.close () here I believe you have a deeper understanding of "the introduction and example usage of echo server in python", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!