[Python] Cant send a command using socket

Discussão em 'Python' iniciado por Stack, Abril 9, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use socket to send a command to a vertex channel emulator. The script is establishing a telnet connection. I know the code is connecting to the vertex as the received response gives "Vertex>" however, on the emulator I can't see a record of the command being sent. I am expecting to see a 'STOPPED' message received as the emulator status is stopped.

    import socket

    HOST="192.168.2.60"
    PORT=3000


    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    print("connected to Vertex")

    command= 'STAT?'
    command_with_termination = f'{command}\n'
    s.send(command_with_termination.encode())
    response= s.recv(1024).decode()
    print(f'Received response: {response}')


    # close the connection
    s.shutdown(1)
    s.close()


    This is the output

    connected to Vertex
    Received response: Vertex>

    Continue reading...

Compartilhe esta Página