5lava avatar 5lava committed e8620b1

Add: EventUtil::getSocketFD() method

Comments (0)

Files changed (3)

classes/event_util.c

 }
 /* }}} */
 
+/* {{{ proto bool EventUtil::getSocketFd(mixed socket)
+ *    Gets numeric file descriptor of a socket. */
+PHP_METHOD(EventUtil, getSocketFd) {
+	zval **ppzfd = NULL;
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z",
+				&ppzfd) == FAILURE) {
+		return;
+	}
+
+	RETVAL_LONG(ppzfd ? php_event_zval_to_fd(ppzfd TSRMLS_CC) : -1);
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
 	ZEND_ARG_INFO(1, port)
 ZEND_END_ARG_INFO();
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_event_util_get_socket_fd, 0, 0, 1)
+	ZEND_ARG_INFO(0, socket)
+ZEND_END_ARG_INFO();
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_event_util_set_socket_option, 0, 0, 4)
 	ZEND_ARG_INFO(0, socket)
 	ZEND_ARG_INFO(0, level)
 	PHP_ME(EventUtil, sslRandPoll,           arginfo_event__void,                ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 #endif
 	PHP_ME(EventUtil, getSocketName,   arginfo_event_util_get_socket_name,   ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+	PHP_ME(EventUtil, getSocketFd,     arginfo_event_util_get_socket_fd,     ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 	PHP_ME(EventUtil, setSocketOption, arginfo_event_util_set_socket_option, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 
 	PHP_FE_END
 PHP_METHOD(EventUtil, sslRandPoll);
 #endif
 PHP_METHOD(EventUtil, getSocketName);
+PHP_METHOD(EventUtil, getSocketFd);
 PHP_METHOD(EventUtil, setSocketOption);
 
 PHP_METHOD(EventBufferPosition, __construct);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.