Fix compilation on OS X

OS X doesn't implement SOL_TCP so workaround this the same way as on
FreeBSD/Solaris.