I have recently starting learning network programming with python. Here is a simple server I tried to write:
import socket
def server():
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('127.0.0.1', 1024))
while True:
data, address = sock.recvfrom(65535)
text = data.decode('ascii')
print('the client from {0} sent: "{1}"'.format(address, text))
if text is '0': break
I wanted the server to wait till it is getting packets from the server, but when I run it, it will close instantly. what did I do wrong?