Skip to content

Commit cc7ca13

Browse files
committed
[SocketClient] Remove ConnectorInterface::createUdp
It does not make sense to represent UDP as a stream. Streams have end semantics, UDP does not.
1 parent c7488bf commit cc7ca13

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

Connector.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,9 @@ public function createTcp($host, $port)
3030
});
3131
}
3232

33-
public function createUdp($host, $port)
33+
public function createSocketForAddress($address, $port)
3434
{
35-
$that = $this;
36-
37-
return $this
38-
->resolveHostname($host)
39-
->then(function ($address) use ($port, $that) {
40-
return $that->createSocketForAddress($address, $port, 'udp');
41-
});
42-
}
43-
44-
public function createSocketForAddress($address, $port, $transport = 'tcp')
45-
{
46-
$url = $this->getSocketUrl($address, $port, $transport);
35+
$url = $this->getSocketUrl($address, $port);
4736

4837
$socket = stream_socket_client($url, $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
4938

@@ -95,9 +84,9 @@ public function handleConnectedSocket($socket)
9584
return new Stream($socket, $this->loop);
9685
}
9786

98-
protected function getSocketUrl($host, $port, $transport)
87+
protected function getSocketUrl($host, $port)
9988
{
100-
return sprintf('%s://%s:%s', $transport, $host, $port);
89+
return sprintf('tcp://%s:%s', $host, $port);
10190
}
10291

10392
protected function resolveHostname($host)

ConnectorInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
interface ConnectorInterface
66
{
77
public function createTcp($host, $port);
8-
public function createUdp($host, $port);
98
}

SecureConnector.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,4 @@ public function createTcp($host, $port)
3131
});
3232
});
3333
}
34-
35-
public function createUdp($host, $port)
36-
{
37-
return When::reject(new \RuntimeException('Secured UDP connection is not supported.'));
38-
}
3934
}

0 commit comments

Comments
 (0)