utils: add functions to more easily manage sockets