tcp: restructure socket option handling