Moved opening of socket to open() and added close() to properly close
the socket.