import socket,struct
def sendreq(data):
    s=socket.create_connection(('127.0.0.1',9000),4)
    s.settimeout(5)
    s.sendall(data)
    out=b''
    try:
        while True:
            c=s.recv(65536)
            if not c: break
            out+=c
    except socket.timeout: pass
    return out
# FCGI_GET_VALUES (type 9)
r=sendreq(struct.pack('!BBHH',1,9,0,8)+struct.pack('!HB',0,0)+b'FCGI_MAX_CONNS'+b'\x00')
print('GET_VALUES:',repr(r[:200]))
# garbage
r=sendreq(b'GET / HTTP/1.0\r\n\r\n')
print('GARBAGE:',repr(r[:200]))
# empty
r=sendreq(b'')
print('EMPTY:',repr(r[:100]))
