set stream options before casting to socket to avoid lost of options, making connections failed from time to time