Permalink
Browse files

Merge pull request #279 from tarasfrompir/master

Убраны излишки в создании сокета
  • Loading branch information...
T-REX-XP committed Sep 13, 2018
2 parents f9254d9 + 5e3365b commit ee52d973350e8f7b89d937869d10a3803d029a17
Showing with 11 additions and 12 deletions.
  1. +11 −12 modules/ssdp_finder/upnp/vendor/jalder/upnp/src/Core.php
@@ -15,22 +15,22 @@ public function __construct()
public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from = null, $port = null, $sockTimout = '2')
{
//create the socket
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
// поиск устройств milight, MagicHome
$request = 'HF-A11ASSISTHREAD'."\r\n";
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 48899);
//поиск устройств yeelight
$request = 'M-SEARCH * HTTP/1.1'."\r\n";
$request = 'M-SEARCH * HTTP/1.1'."\r\n";
$request .= 'HOST: 239.255.255.250:1982'."\r\n";
$request .= 'MAN: "'.$man.'"'."\r\n";
$request .= 'MX: '.$mx.''."\r\n";
$request .= 'ST: wifi_bulb'."\r\n";
$request .= 'MX: '.$mx.''."\r\n";
$request .= 'ST: wifi_bulb'."\r\n";
$request .= "\r\n";
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 1982);
//all
@@ -41,13 +41,12 @@ public function search($st = 'ssdp:all', $mx = 2, $man = 'ssdp:discover', $from
$request .= 'ST: '.$st.''."\r\n";
$request .= 'USER-AGENT: '.$this->user_agent."\r\n";
$request .= "\r\n";
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_BROADCAST, true);
// search device of other net
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 1900);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'50'));
// search device of you PC
socket_sendto($socket, $request, strlen($request), 0, '255.255.255.255', 1900);
// search device of other net
socket_sendto($socket, $request, strlen($request), 0, '239.255.255.250', 1900);
// send the data from socket
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec'=>$sockTimout, 'usec'=>'50'));
$response = array();
do {

0 comments on commit ee52d97

Please sign in to comment.