added curl paramater, DEFAULT FALSE, it indicates
whether to use curl protocol or a socket.
added socket connection