Releases: reactphp-legacy/socket-client
v0.7.0
-
Feature / BC break: Add main
Connector
facade
(#93 by @clue)The new
Connector
class acts as a facade for all underlying connectors,
which are now marked as "advanced usage", but continue to work unchanged.
This now makes it trivially easy to create plaintext TCP/IP, secure TLS and
Unix domain socket (UDS) connection streams simply like this:$connector = new Connector($loop); $connector->connect('tls://google.com:443')->then(function (ConnectionInterface $conn) { $conn->write("GET / HTTP/1.0\r\n\r\n"); });
Optionally, it accepts options to configure all underlying connectors, such
as using a custom DNS setup, timeout values and disabling certain protocols
and much more. See the README for more details.
v0.6.2
v0.6.1
v0.6.0
-
Feature / BC break: Use
connect($uri)
instead ofcreate($host, $port)
and resolve with aConnectionInterface
instead ofStream
and expose remote and local addresses through this interface
and remove superfluous and undocumentedConnectionException
.
(#74, #82 and #84 by @clue)// old $connector->create('google.com', 80)->then(function (Stream $conn) { echo 'Connected' . PHP_EOL; $conn->write("GET / HTTP/1.0\r\n\r\n"); }); // new $connector->connect('google.com:80')->then(function (ConnectionInterface $conn) { echo 'Connected to ' . $conn->getRemoteAddress() . PHP_EOL; $conn->write("GET / HTTP/1.0\r\n\r\n"); });
Note that both the old
Stream
and the newConnectionInterface
implement
the same underlyingDuplexStreamInterface
, so their streaming behavior is
actually equivalent.
In order to upgrade, simply use the new typehints.
Existing stream handlers should continue to work unchanged. -
Feature / BC break: All connectors now MUST offer cancellation support.
You can now rely on getting a rejected promise when callingcancel()
on a
pending connection attempt.
(#79 by @clue)// old: promise resolution not enforced and thus unreliable $promise = $connector->create($host, $port); $promise->cancel(); $promise->then(/* MAY still be called */, /* SHOULD be called */); // new: rejecting after cancellation is mandatory $promise = $connector->connect($uri); $promise->cancel(); $promise->then(/* MUST NOT be called */, /* MUST be called */);
Note that this behavior is only mandatory for pending connection attempts.
Once the promise is settled (resolved), callingcancel()
will have no effect. -
BC break: All connector classes are now marked
final
and you can no longerextend
them
(which was never documented or recommended anyway).
Please use composition instead of extension.
(#85 by @clue)
v0.5.3
v0.5.2
v0.4.6
This is a bugfix release that resolves an issue introduced in the v0.4.5 release.
You should consider upgrading to the v0.5 release.
- Fix: Always create empty stream context to prevent race condition leading to
CN mismatch on TLS enabled connections (#73 by @WyriHaximus)
v0.5.1
-
Feature: Support Promise cancellation for all connectors
(#71 by @clue)$promise = $connector->create($host, $port); $promise->cancel();
-
Feature: Add TimeoutConnector decorator
(#51 by @clue)$timeout = new TimeoutConnector($connector, 3.0, $loop); $timeout->create($host, $port)->then(function(Stream $stream) { // connection resolved within 3.0s });
v0.4.5
v0.5.0
-
Feature / BC break: Support Connector without DNS
(#46 by @clue)BC break: The
Connector
class now serves as a BC layer only.
TheTcpConnector
andDnsConnector
classes replace its functionality.
If you're merely using this class, then you're recommended to upgrade as
per the below snippet – existing code will still work unchanged.
If you'reextend
ing theConnector
(generally not recommended), then you
may have to rework your class hierarchy.// old (still supported, but marked deprecated) $connector = new Connector($loop, $resolver); // new equivalent $connector = new DnsConnector(new TcpConnector($loop), $resolver); // new feature: supports connecting to IP addresses only $connector = new TcpConnector($loop);
-
Feature: Add socket and SSL/TLS context options to connectors
(#52 by @clue) -
Fix: PHP 5.6+ uses new SSL/TLS context options
(#61 by @clue) -
Fix: Move SSL/TLS context options to SecureConnector
(#43 by @clue) -
Fix: Fix error reporting for invalid addresses
(#47 by @clue) -
Fix: Close stream resource if connection fails
(#48 by @clue) -
First class support for PHP 5.3 through PHP 7 and HHVM
(#53, #54 by @clue)