--- /Users/chris/Downloads/OpenLDAP-106/OpenLDAP/libraries/libldap/os-ip.c.bak
+++ os-ip.c
@@ -144,6 +144,25 @@
 	}
 #endif
 
+#ifdef SO_SNDTIMEO
+  // If we have a defined network timeout we'll set that at the socket
+  // level so the various ldap APIs which lack timeouts will get the
+  // network-level failure instead:
+  
+  if ( (tv = ld->ld_options.ldo_tm_net) != NULL ) {
+    if (0 != setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv))) {
+      osip_debug(ld, 
+				"ldap_int_prepare_socket(): setsockopt() failed to set SO_SNDTIMEO: %s\n", 
+				strerror(errno), NULL, NULL);
+    }
+    if (0 != setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv))) {
+      osip_debug(ld, 
+				"ldap_int_prepare_socket(): setsockopt() failed to set SO_RCVTIMEO: %s\n", 
+				strerror(errno), NULL, NULL);
+    }
+  }
+#endif
+
 	int flag = 1;
 	if(ld->ld_options.ldo_noaddr_option == 1) {
 		if ( setsockopt( s, SOL_SOCKET, SO_NOADDRERR,
