是的,PHP的socket_create
函數(shù)支持創(chuàng)建UDP套接字??梢酝ㄟ^指定SOCK_DGRAM
參數(shù)來創(chuàng)建UDP套接字。以下是一個簡單的示例:
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!$socket) {
echo "Failed to create socket: " . socket_strerror(socket_last_error());
} else {
echo "UDP socket created successfully";
}
// 使用socket操作
socket_close($socket);