php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63472
Patch sockets_SO_BINDTODEVICE.diff revision 2012-11-09 15:14 UTC by zobo at scene-si dot org

Patch sockets_SO_BINDTODEVICE.diff for Sockets related Bug #63472

Patch version 2012-11-09 15:14 UTC

Return to Bug #63472 | Download this patch
Patch Revisions:

Developer: zobo@scene-si.org

diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 4adb09f..982bfcf 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -801,6 +801,9 @@ PHP_MINIT_FUNCTION(sockets)
 	REGISTER_LONG_CONSTANT("SO_RCVTIMEO",	SO_RCVTIMEO,	CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("SO_TYPE",		SO_TYPE,		CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("SO_ERROR",		SO_ERROR,		CONST_CS | CONST_PERSISTENT);
+#ifdef SO_BINDTODEVICE
+	REGISTER_LONG_CONSTANT("SO_BINDTODEVICE",       SO_BINDTODEVICE,        CONST_CS | CONST_PERSISTENT);
+#endif
 	REGISTER_LONG_CONSTANT("SOL_SOCKET",	SOL_SOCKET,		CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("SOMAXCONN",		SOMAXCONN,		CONST_CS | CONST_PERSISTENT);
 #ifdef TCP_NODELAY
@@ -2315,11 +2318,16 @@ ipv6_loop_hops:
 		}
 		
 		default:
-			convert_to_long_ex(arg4);
-			ov = Z_LVAL_PP(arg4);
+			if (Z_TYPE_PP(arg4) == IS_STRING) {
+				opt_ptr = Z_STRVAL_PP(arg4);
+				optlen = Z_STRLEN_PP(arg4);
+			} else {
+				convert_to_long_ex(arg4);
+				ov = Z_LVAL_PP(arg4);
 
-			optlen = sizeof(ov);
-			opt_ptr = &ov;
+				optlen = sizeof(ov);
+				opt_ptr = &ov;
+			}
 			break;
 	}
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC