fixed issue causing immediate disconnection of socket

issue was: the code, as written, was disconnecting as soon as it processed a message.  This has been fixed in the commit.