$OpenBSD: patch-Modules_socketmodule_c,v 1.5 2009/01/01 21:03:27 djm Exp $
--- Modules/socketmodule.c.orig	Wed Oct 11 02:20:41 2006
+++ Modules/socketmodule.c	Fri Dec 26 12:27:16 2008
@@ -72,9 +72,6 @@ Local naming conventions:
 
 #include "Python.h"
 
-#undef MAX
-#define MAX(x, y) ((x) < (y) ? (y) : (x))
-
 /* Socket object documentation */
 PyDoc_STRVAR(sock_doc,
 "socket([family[, type[, proto]]]) -> socket object\n\
@@ -1807,10 +1804,15 @@ internal_connect(PySocketSockObject *s, struct sockadd
 
 	if (s->sock_timeout > 0.0) {
 		if (res < 0 && errno == EINPROGRESS && IS_SELECTABLE(s)) {
+			socklen_t res_size = sizeof res;
+			int save_errno;
+
 			timeout = internal_select(s, 1);
-			res = connect(s->sock_fd, addr, addrlen);
-			if (res < 0 && errno == EISCONN)
-				res = 0;
+			save_errno = errno;
+			(void)getsockopt(s->sock_fd, SOL_SOCKET, SO_ERROR,
+			    &res, &res_size);
+			errno = save_errno;
+			res = res ? -1 : 0;
 		}
 	}
 
@@ -3307,7 +3309,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
 
 #if !defined(HAVE_INET_ATON) || defined(USE_INET_ATON_WEAKLINK)
 	/* Have to use inet_addr() instead */
-	unsigned long packed_addr;
+	int packed_addr;
 #endif
 	char *ip_addr;
 
