Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ext/sockets/sockaddr_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, zend_string
}
#endif
else {
php_error_docref(NULL, E_WARNING,
"IP address used in the context of an unexpected type of socket");
zend_value_error("IP address used in the context of an unexpected type of socket");
}
return 0;
}
30 changes: 30 additions & 0 deletions ext/sockets/tests/mcast_sockettype_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Multicast attempt on unsupported socket type
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows!');
}
?>
--FILE--
<?php
$sock_path = sprintf("/tmp/%s.sock", uniqid());

if (file_exists($sock_path))
die('Temporary socket already exists.');
$sock = socket_create(AF_UNIX, SOCK_DGRAM, 0);
socket_bind($sock, $sock_path);

try {
socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
"group" => '127.0.0.1',
"interface" => "lo",
));
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
IP address used in the context of an unexpected type of socket
Loading