python - ZMQ script - send only one message and wait for full reply -


i'm having problems python script, used control game server ( quakelive) via rcon ( can send commands , executed on server - changing map or password ).

game developers provided such script. written using zeromq library, problem takes commands standard input ( first go queue , sent server ) , when there no commands in stdin, waits them.

and make send / execute 1 command, finish connection , 'go further', i'm pretty new python , zeromq, i'm kinda lost.

this script: https://github.com/marconett/quakelive-docker/blob/master/zmq_rcon.py.

also, deduced testing, server needs send full reply ( it's 2 lines, 10 ) otherwise gets suspended.

yes.
in zeromq reply needed req/rep formal pattern.

first, let's demystify problem.

zeromq lovely piece of code. it's scaleable formal communication pattern name somehow resembles going on, if respective counterparties strive use such formal behaviour.

having taken line 114, rep/rep being used, req asks , rep has answer ( , req-side has receive / "read" ), before req can send request-message rep-side:

    ...     server_rep = server_ctx.socket( zmq.rep )        # ____________.rep archetype     server_rep.bind( host )                          #                ^ |     ...                                              #                | v     client_socket_1 = client_ctx_1.socket( zmq.req ) # ____________.req archetype     client_socket_1.connect( host )     ...     client_socket_2 = client_ctx_2.socket( zmq.req ) # ____________.req archetype     client_socket_2.connect( host ) 

so, irrespective, whether initial source-data, going sent rep, came stdin, fileio .readline() or zeromq-pattern socket-endpoint, each req-message has re-unlocked rep-message ( on rpc-remote-side, code strives send 1 command server , quit ).

so, server-side code responsible well-designed code, not one.


Comments