Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To hide "socket_import_stream(): cannot represent a stream of type tcp_socket/ssl as a Socket Descriptor" #126

Open
manoletto opened this issue Nov 23, 2019 · 1 comment

Comments

@manoletto
Copy link

manoletto commented Nov 23, 2019

To set the TCP_NODELAY socket option only when it is possible,
and disable warning message :

socket_import_stream(): cannot represent a stream of type tcp_socket/ssl as a Socket Descriptor

in Wrench/lib/Socket/ServerSocket.php accept() method (on line 67),

i suggest this :

        if (!$new) {
            throw new ConnectionException(socket_strerror(socket_last_error($new)));
        }

++      if(($sock = @socket_import_stream($new))>0){
--      socket_set_option(socket_import_stream($new), SOL_TCP, TCP_NODELAY, 1);
++       	socket_set_option($sock, SOL_TCP, TCP_NODELAY, 1);
++      }

        return $new;
@manoletto
Copy link
Author

Better solution :

in Wrench/lib/Socket/ServerSocket.php getSocketStreamContextOptions() method,

add

$options['tcp_nodelay'] = TRUE;

and remove socket_set_option() call in accept() method.

It works ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant