This is a piece of #21878, chopped off to ease review.
Add a virtual (thus mockable) method Sock::SetSockOpt() that wraps the system setsockopt().
Convert the standalone SetSocketNoDelay() function to a virtual (thus mockable) method Sock::SetNoDelay().
This will help avoid syscalls during testing and to mock them to return whatever is suitable for the tests.