Skip to content

Commit af70784

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

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-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_type_error("IP address used in the context of an unexpected type of socket");
142141
}
143142
return 0;
144143
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Multicast attempt on unsupported socket type
3+
--EXTENSIONS--
4+
sockets
5+
--FILE--
6+
<?php
7+
$sock = socket_create(AF_UNIX, SOCK_DGRAM, 0);
8+
socket_bind($sock, '0.0.0.0', 0);
9+
10+
try {
11+
socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
12+
"group" => '127.0.0.1',
13+
"interface" => "lo",
14+
));
15+
} catch (\TypeError $e) {
16+
echo $e->getMessage(), PHP_EOL;
17+
}
18+
?>
19+
--EXPECT--
20+
IP address used in the context of an unexpected type of socket

0 commit comments

Comments
 (0)