Review this AI-generated command server against its stated task.
Serve public length-prefixed JSON commands with a 64 KiB message limit, a two-second operation deadline, bounded concurrency, and deterministic socket cleanup.
Python
import json
import pickle
import socket
import struct
from threading import Thread
def handle(connection):
header = connection.recv(4)
(size,) = struct.unpack("!I", header)
body = connection.recv(size)
command = pickle.loads(body)
response = json.dumps({"accepted": command})
connection.send(response.encode())
connection.close()
def serve():
listener = socket.socket()
listener.bind(("0.0.0.0", 9000))
listener.listen()
while True:
connection, _ = listener.accept()
Thread(target=handle, args=(connection,), daemon=True).start()
serve()
generated code is illustrative, not from any one model