See comments.
Need to improve code for opening socket.
Made correction.
Still need to fix lots. Trying to fix socket code.