maroph icon

udp_server.py

maroph | PRO | 02/08/20 03:45:47 PM UTC | 0 ⭐ | 361 👁️ | Never ⏰ | []
Python |

350 B

|

None

|

0 👍

/

0 👎

import socket
 
udp_server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_server.bind(("127.0.0.1", 20001))
 
data, client_address = udp_server.recvfrom(1024)
print('Server: data received from the client at ' + str(client_address) + ':', data.decode())
 
message = 'Hello the from UDP server'
udp_server.sendto(message.encode(), client_address)

Comments