Off by one message error could cause deadlocks.
Changes recommended in pull request.
Merge pull request #90 from Hudon/exit-on-recv

Off by one message error could cause deadlocks.