pythonserializationrabbitmqzeromqsimplexmlrpcserver

How to change the value of a variable at run time from another script at remote machine?


I have a local computer A and remote computer B. Computer A has script client.py Computer B has server.py Script client.py has a variable port. Let's say port = 5535.

I am running client.py on Computer A, which is using the port number for socket communication. I need to change the port number to another port number while the client.py is running so it will switch to another server at runtime after notifying the client to change the port number. I am using pyzmq to send data from the client to the server sending a continuous stream of data.

Is this scenario possible and how can I do it?


Solution

  • Yes, it's possible. You may design / modify the (so far unseen) code so as to PUSH any such need to change a port# on-the-fly to the PULL-side, to release the 5535 and use another one.

    The PULL-side shall then call .disconnect() and .close() methods, so as to release the said port 5535 ( plus notify that it has done so, perhaps by another PUSH/PULL to the .bind()-locked party, that it can now unbind and close the .bind()-locked port# 5535 too) and next setup a new connection to an announced "new_port#", received from the initial notification ( which ought have been already .bind()-locked on the PUSH-side, ought it not? :o) ).

    That easy.