Could you do this?
var myListener = ogscript.getListenerById('myListener');
myListener.stop();
myListener.connecthost = '192.168.1.1';
myListener.connectport = '12345';
myListener.start();
I don't know if those are writable values to the listener object or not, the documentation was not clear.
I currently do it like this in my panels:
<listener autostart="false" connecthost="%const['hosts']['device1.address']%" connectport="%const['hosts']['device1.port']%" delimitertype="newline" id="myListener">
And then I have those host/port values defined in my lookups:
<lookup access="1" id="hosts">
<entry key="device1.address">192.168.1.1</entry>
<entry key="device1.port">12345</entry>
</lookup>
So if the first method doesn't work, maybe you could programmatically stop the listener, change the lookup key values, and then restart the listener. I haven't tried it, so just a guess!
#DashBoard