Move socket and collection functions to a convenience library

This avoids the iproxy tool from relying on undocumented library ABI.
Use -fvisibility=hidden