Skip to content

Commit 79884f9

Browse files
committed
ext/sockets: multicast on unsupported socket type error change.
From a mere warning to an exception.
1 parent a402eda commit 79884f9

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

ext/sockets/sockaddr_conv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, zend_string
137137
}
138138
#endif
139139
else {
140-
php_error_docref(NULL, E_WARNING,
141-
"IP address used in the context of an unexpected type of socket");
140+
zend_value_error("IP address used in the context of an unexpected type of socket");
142141
}
143142
return 0;
144143
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Multicast attempt on unsupported socket type
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php
7+
if (substr(PHP_OS, 0, 3) == 'WIN') {
8+
die('skip Not for Windows!');
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
$sock_path = sprintf("/tmp/%s.sock", uniqid());
14+
15+
if (file_exists($sock_path))
16+
die('Temporary socket already exists.');
17+
$sock = socket_create(AF_UNIX, SOCK_DGRAM, 0);
18+
socket_bind($sock, $sock_path);
19+
20+
try {
21+
socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
22+
"group" => '127.0.0.1',
23+
"interface" => "lo",
24+
));
25+
} catch (\ValueError $e) {
26+
echo $e->getMessage(), PHP_EOL;
27+
}
28+
?>
29+
--EXPECT--
30+
IP address used in the context of an unexpected type of socket

0 commit comments

Comments
 (0)