Move socket stuff into socket.c