@@ -101,6 +101,17 @@ static int socket_close(php_stream *stream, int close_handle);
101101static int socket_stat (php_stream *stream, php_stream_statbuf *ssb);
102102static int socket_cast (php_stream *stream, int castas, void **ret);
103103static bool socket_ssl_set_options (Socket *sock, php_stream_context *context);
104+
105+ static php_stream *socket_create (const char *proto,
106+ size_t protolen,
107+ const char *resourcename,
108+ size_t resourcenamelen,
109+ const char *persistent_id,
110+ int options,
111+ int flags,
112+ struct timeval *timeout,
113+ php_stream_context *context STREAMS_DC);
114+
104115// clang-format off
105116static zend_class_entry *swoole_runtime_ce;
106117
@@ -284,6 +295,13 @@ void php_swoole_runtime_minit(int module_number) {
284295#endif
285296 swoole_proc_open_init (module_number);
286297
298+ php_stream_xport_register (" async.tcp" , socket_create);
299+ php_stream_xport_register (" async.udp" , socket_create);
300+ php_stream_xport_register (" async.unix" , socket_create);
301+ php_stream_xport_register (" async.udg" , socket_create);
302+ php_stream_xport_register (" async.ssl" , socket_create);
303+ php_stream_xport_register (" async.tls" , socket_create);
304+
287305 php_register_url_stream_wrapper (SW_ASYNC_FILE_PROTOCOL, &sw_php_plain_files_wrapper);
288306}
289307
@@ -1214,6 +1232,11 @@ static php_stream *socket_create(const char *proto,
12141232 proto, protolen, resourcename, resourcenamelen, persistent_id, options, flags, timeout, context STREAMS_CC);
12151233 }
12161234
1235+ if (SW_STR_STARTS_WITH (proto, protolen, " async." )) {
1236+ proto += sizeof (" async." ) - 1 ;
1237+ protolen -= sizeof (" async." ) - 1 ;
1238+ }
1239+
12171240 if (SW_STREQ (proto, protolen, " tcp" )) {
12181241 sock = new Socket (resourcename[0 ] == ' [' ? SW_SOCK_TCP6 : SW_SOCK_TCP);
12191242 } else if (SW_STREQ (proto, protolen, " ssl" ) || SW_STREQ (proto, protolen, " tls" )) {
0 commit comments