Silently handle socket errors in the UdpAdapter (closes #27), add testcase

Conflicts:
	tests/ClientTest.php
This commit is contained in:
Evan Darwin
2015-06-21 17:56:18 +02:00
committed by Walter Dal Mut
parent 27c19c9e4b
commit c6e7b744c3
+9
View File
@@ -15,9 +15,18 @@ final class UdpAdapter extends AdapterAbstract
public function write($message)
{
// Create a handler in order to handle the 'Host is down' message
set_error_handler(function() {
// Suppress the error, this is the UDP adapter and if we can't send
// it then we shouldn't inturrupt their application.
});
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_sendto($socket, $message, strlen($message), 0, $this->getOptions()->getHost(), $this->getOptions()->getPort());
socket_close($socket);
// Remove our error handler.
restore_error_handler();
}
private function serialize(array $message)