Hi,
you can get any help from pfsockopen() function for persistent connection, else if this not so usefull: it's persistent only in the same process.
Another ideas may be this:
Do you cannot separate socket script from function script?
You can make a first script. This first, do socket connection and listen for command. Then when receive a command execute as system call a second php script, with command as parameter. This second can be updated without any reconnection.
I hope all this make a sense...