简体   繁体   中英

Send an http request through UDP

I need to send a simple http request to trigger an event through UDP protocol, I don't need to receive the response

Is it possible and how can I do it with php

I think it should help you:

$server_ip = '127.0.0.1';
$server_port = 43278;
$message = 'Message';
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_sendto($socket, $message, strlen($message), 0, $server_ip, $server_port);
socket_close($socket);

More informations you can get at PHP MANUAL: socket_sendto

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM