Socket now recognizes connection with client. Removed old code and fixed undefined variable errors arising from sock