--- sockets.c Mon Oct 15 13:12:12 2001 +++ newsockets.c Mon Oct 15 13:13:39 2001 @@ -548,14 +548,12 @@ php_fd_set *rfds = NULL, *wfds = NULL, *xfds = NULL; SOCKET max_fd; int sets = 0; + int argc = ZEND_NUM_ARGS(); - if (zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { + if (argc < 3 || argc > 5 || zend_get_parameters_ex(argc, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long_ex(arg4); - convert_to_long_ex(arg5); - if (Z_TYPE_PP(arg1) == IS_RESOURCE) { ZEND_FETCH_RESOURCE(rfds, php_fd_set*, arg1, -1, le_destroy_name, le_destroy); max_fd = rfds->max_fd; @@ -575,17 +573,27 @@ } if (!sets) { - php_error(E_ERROR, "expecting atleast one %s in %s()", le_destroy_name, get_active_function_name(TSRMLS_C)); + php_error(E_ERROR, "expecting at least one %s in %s()", le_destroy_name, get_active_function_name(TSRMLS_C)); RETURN_FALSE; } - tv.tv_sec = Z_LVAL_PP(arg4); - tv.tv_usec = Z_LVAL_PP(arg5); + if (argc > 3) + { + convert_to_long_ex(arg4); + tv.tv_sec = Z_LVAL_PP(arg4); + if (argc > 4) + { + convert_to_long_ex(arg5); + tv.tv_usec = Z_LVAL_PP(arg5); + } + else + tv.tv_usec = 0; + } RETURN_LONG(select(max_fd+1, rfds ? &(rfds->set) : NULL, wfds ? &(wfds->set) : NULL, xfds ? &(xfds->set) : NULL, - &tv)); + ((argc > 3) ? &tv : NULL))); } /* }}} */