def send_port(port, command, arguments="", timeout=None):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    if timeout is not None:
        sock.settimeout(timeout)
    errno = sock.connect_ex(('localhost', port))
    if errno:
        sock.close()
        return False

    try:
        send(sock, command, arguments)
    except socket.error:
        return False
    finally:
        try:
            sock.shutdown(socket.SHUT_WR)
        except:
            pass
    return True
A send a command to a port. Convenience function that uses 'send'.
dataset/ETHPy150Open enthought/envisage/envisage/plugins/remote_editor/communication/util.py/send_port