Append $rand or $ticks to the socket name, you can then create dynamically named variables (or create a hash table) using $sockname. That will stop different calls from interfering with one another.

If you're concerned about operations taking too long and the socket closing, fetch all the information from the socket and write it to a file before acting on it.