from socket import *    #import networking tools
serverPort = 8000   #server port
serverSocket = socket(AF_INET,SOCK_STREAM)  #setup an ipv4 (AF_INET) socket that can access networks through TCP (SOCK_STREAM)
serverSocket.bind(("", serverPort))
serverSocket.listen(1)
print("サーバは準備ができています〜")
while True:
    connectionSocket, address = serverSocket.accept()   #Accept the client's handshake
    m = connectionSocket.recv(1024).decode()    #Store the client's 1024 bits as a decoded variable called `m`

    r = str(len(m)) #Store the length of `m` as `r`
    connectionSocket.send(r.encode())   #Encode `r` in UTF-8 and send it
    connectionSocket.close()    #End the session
