libstd: Get rid of duplication in {peer, socket}_name.