Fix compilation error for Socket on older linux + OSX.

Test whether SOCK_NONBLOCK and SOCK_CLOEXEC are defined to use single system call to create socket.
Otherwise use os::nonblock and os::cloexec after creating the socket.

Review: https://reviews.apache.org/r/28125