Skip to content Skip to sidebar Skip to footer

Create An Echo Server

I am new to python and trying to code. I want to create simple echo server ie whatever I input to the client will simply be echo back by the server and if the client user press ent

Solution 1:

The result will contain a newline, but you can simply call str.strip to filter that out:

conn.send("\nEnter your name.\n")
data = conn.recv(2048)
if not data.strip():
    print('Please enter a name')
    return 1
print("Client name is : ", data)

Post a Comment for "Create An Echo Server"