

def receive(sock):
    " Receive a command with arguments from a socket that was previously sent\n        information with 'send'.\n    "
    index = (- 1)
    (chunk, length) = (encode(''), encode(''))
    received = False
    while (not received):
        (readers, writers, in_error) = select.select([sock], [], [], 60)
        for rsock in readers:
            while (index == (- 1)):
                length += chunk
                chunk = rsock.recv(4096)
                if (not chunk):
                    raise socket.error
                index = chunk.find(encode(MESSAGE_SEP))
            length = int((length + chunk[:index]))
            msg = chunk[(index + 1):]
            while (len(msg) < length):
                chunk = rsock.recv((length - len(msg)))
                if (not chunk):
                    raise socket.error
                msg += chunk
            received = True
    (command, sep, arguments) = msg.partition(encode(MESSAGE_SEP))
    return (decode(command), decode(arguments))

dataset/ETHPy150Open enthought/envisage/envisage/plugins/remote_editor/communication/util.py receive/original