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

[Improvement] Replace fsockopen with stream_socket_client #9

Closed
mfuehrer82 opened this issue Jun 15, 2017 · 1 comment
Closed

[Improvement] Replace fsockopen with stream_socket_client #9

mfuehrer82 opened this issue Jun 15, 2017 · 1 comment

Comments

@mfuehrer82
Copy link

The stream extension has a lot more configuration options.

See further:
http://php.net/manual/en/intro.stream.php

@hollodotme
Copy link
Owner

hollodotme commented Jun 15, 2017

Seems this will lead to a little BC break as stream_socket_client() expects the remote socket address instead of just host and port which fsockopen() requires.

So I'll change the interface of hollodotme\FastCGI\Interfaces\ConfiguresSocketConnection from:

<?php declare(strict_types=1);

interface ConfiguresSocketConnection
{
	public function getHost() : string;

	public function getPort() : int;

	public function getConnectTimeout() : int;

	public function getReadWriteTimeout() : int;
}

to:

<?php declare(strict_types=1);

interface ConfiguresSocketConnection
{
	public function getSocketAddress() : string;

	public function getConnectTimeout() : int;

	public function getReadWriteTimeout() : int;
}

Furthermore the remote socket address requires a transport protocol which is tcp:// for network sockets and unix:// for unix domain sockets. To make the first parameters of NetworkSocket and UnixDomainSocket constructors consistent, the transport protocol must be omitted in both cases. That means creating a UnixDomainSocket connection must be constructed like this:

<?php declare(strict_types=1);

# Only the socket path must be passed
$connection = new UnixDomainSocket( '/var/run/php/php7.1-fpm.sock' );

Until now it was:

<?php declare(strict_types=1);

$connection = new UnixDomainSocket( 'unix:///var/run/php/php7.1-fpm.sock' );

The transport protocol will be statically added by the both connection classes.

hollodotme added a commit that referenced this issue Jun 15, 2017
…cy to connection parameters, #9

Changed

* Replaced methods `getHost()` and `getPort()` with `getSocketAddress()` in interface `hollodotme\FastCGI\Interfaces\ConfiguresSocketConnection`
* The transport protocol `unix://` must be omitted for the first parameter of `hollodotme\FastCGI\SocketConnections\UnixDomainSocket`
  Only the socket path must be passed.
* Relaced `fsockopen()` with `stream_socket_client()` for connecting to php-fpm.
@hollodotme hollodotme self-assigned this Jun 15, 2017
@hollodotme hollodotme modified the milestones: v1.3.0, v1.3.0/v2.3.0 Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants