Refactored code based on comments.

Communicator constructor now requires 2 arguments ipaddress and port.
Made error messages more descriptive.
Added error handling for a failed close.
Improved documentation