Moved socket code around in prep for REQ/REP sockets