split of socket utility functions into socket.c