Skip to content

Commit f814144

Browse files
committed
Adjust all addresses passed to factory
1 parent 3ea2375 commit f814144

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $loop = React\EventLoop\Factory::create();
1212

1313
$factory = new Datagram\Factory($loop);
1414

15-
$factory->createClient('localhost', 1234)->then(function (Datagram\Socket $client) use ($loop) {
15+
$factory->createClient('localhost:1234')->then(function (Datagram\Socket $client) {
1616
$client->send('first');
1717

1818
$client->on('message', function($message, $serverAddress, $client) {

example/client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
$factory = new Datagram\Factory($loop, $resolver);
1111

12-
$factory->createClient('localhost', 1234)->then(function (Datagram\Socket $client) use ($loop) {
12+
$factory->createClient('localhost:1234')->then(function (Datagram\Socket $client) use ($loop) {
1313
$client->send('first');
1414

1515
$client->on('message', function($message, $serverAddress, $client) {

example/server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
$factory = new Datagram\Factory($loop);
88

9-
$factory->createServer(1234)->then(function (Datagram\Socket $server) {
9+
$factory->createServer('localhost:1234')->then(function (Datagram\Socket $server) {
1010
$server->on('message', function($message, $address, $server) {
1111
$server->send('hello ' . $address . '! echo: ' . $message, $address);
1212

tests/FactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp()
1616

1717
public function testCreateClient()
1818
{
19-
$promise = $this->factory->createClient('127.0.0.1', 12345);
19+
$promise = $this->factory->createClient('127.0.0.1:12345');
2020

2121
$capturedClient = $this->getValueFromResolvedPromise($promise);
2222
$this->assertInstanceOf('Datagram\Socket', $capturedClient);
@@ -26,7 +26,7 @@ public function testCreateClient()
2626

2727
public function testCreateClientLocalhost()
2828
{
29-
$promise = $this->factory->createClient('localhost', 12345);
29+
$promise = $this->factory->createClient('localhost:12345');
3030

3131
$capturedClient = $this->getValueFromResolvedPromise($promise);
3232
$this->assertInstanceOf('Datagram\Socket', $capturedClient);
@@ -36,7 +36,7 @@ public function testCreateClientLocalhost()
3636

3737
public function testCreateClientIpv6()
3838
{
39-
$promise = $this->factory->createClient('::1', 12345);
39+
$promise = $this->factory->createClient('[::1]:12345');
4040

4141
$capturedClient = $this->getValueFromResolvedPromise($promise);
4242
$this->assertInstanceOf('Datagram\Socket', $capturedClient);
@@ -46,7 +46,7 @@ public function testCreateClientIpv6()
4646

4747
public function testCreateServer()
4848
{
49-
$promise = $this->factory->createServer(12345, '127.0.0.1');
49+
$promise = $this->factory->createServer('127.0.0.1:12345');
5050

5151
$capturedServer = $this->getValueFromResolvedPromise($promise);
5252
$this->assertInstanceOf('Datagram\Socket', $capturedServer);

tests/SocketTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function setUp()
1616

1717
public function testCreateClientCloseWillNotBlock()
1818
{
19-
$promise = $this->factory->createClient('127.0.0.1', 12345);
19+
$promise = $this->factory->createClient('127.0.0.1:12345');
2020
$client = $this->getValueFromResolvedPromise($promise);
2121

2222
$client->send('test');
@@ -40,7 +40,7 @@ public function testClientCloseAgainWillNotBlock(Socket $client)
4040

4141
public function testCreateClientEndWillNotBlock()
4242
{
43-
$promise = $this->factory->createClient('127.0.0.1', 12345);
43+
$promise = $this->factory->createClient('127.0.0.1:12345');
4444
$client = $this->getValueFromResolvedPromise($promise);
4545

4646
$client->send('test');
@@ -77,7 +77,7 @@ public function testClientSendAfterEndIsNoop(Socket $client)
7777

7878
public function testClientSendHugeWillFail()
7979
{
80-
$promise = $this->factory->createClient('127.0.0.1', 12345);
80+
$promise = $this->factory->createClient('127.0.0.1:12345');
8181
$client = $this->getValueFromResolvedPromise($promise);
8282

8383
$client->send(str_repeat(1, 1024 * 1024));
@@ -89,10 +89,10 @@ public function testClientSendHugeWillFail()
8989

9090
public function testCreatePair()
9191
{
92-
$promise = $this->factory->createServer(0, '127.0.0.1');
92+
$promise = $this->factory->createServer('127.0.0.1:0');
9393
$server = $this->getValueFromResolvedPromise($promise);
9494

95-
$promise = $this->factory->createClient('127.0.0.1', $server->getPort());
95+
$promise = $this->factory->createClient($server->getLocalAddress());
9696
$client = $this->getValueFromResolvedPromise($promise);
9797

9898
$that = $this;

0 commit comments

Comments
 (0)