utils: add socket portability functions