After further review, I think this could be made DRYer.  the logic is the same, just one uses "client" and the other "server".