• 0

Send UDP packet


Question

Hi

I have the LightwaveRF home lighting system, which you can supposedly communicate with via UDP packets.  I have tested this from my Windows box using an app called Packet Sender.  I send "001,!F*p" (the initialisation code) in port 9760 to 192.168.0.6 (the LightwaveRF hub).  This triggers the hub to react - simply saying "Not yet linked" - that's far enough for me right now.

I am attempting to do the same via PHP, so this is my script:

<?
$lwrfPort = 9760;
$lwrfIP = '192.168.0.6';
$lwrfInitString = "001,!F*p";
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($sock, SOL_SOCKET, SO_BROADCAST, 1);
socket_sendto($sock, $lwrfInitString, strlen($lwrfInitString), 0 ,$lwrfIP, $lwrfPort);
socket_close($sock);
?>

I get no errors, but it also doesn't do anything - certainly not trigger the hub.

I have tried the following terminal command:

sudo sendip -p ipv4 -is 192.168.0.6 -p udp -us 9760 -ud 9760 -d '001\,!F*p' -v 192.168.0.6

Again nothing...

Can anyone suggest anything obvious I am doing wrong?

Thanks

Link to comment
https://www.neowin.net/forum/topic/1268498-send-udp-packet/
Share on other sites

17 answers to this question

Recommended Posts

  • 0
  On 13/08/2015 at 00:10, EddieF said:

Wild guess here, Perhaps SELinux is stopping it?  SELinux usually logs to /var/log/audit/audit.log  (atleast on CentOS)

This is the log:

[Wed Aug 12 16:29:34.574067 2015] [:error] [pid 3121] [client 192.168.0.5:52634] PHP Warning:  socket_sendto(): unable to write to socket [13]: Permission denied in /var/www/html/info.php on line 7

Hmmmm, what do I need to escalate for permission?

  • 0

I'd try putting SELinx into permissive mode (assuming your using a distro that has it by default) and see if the first command and your PHP script work. I'd be almost willing to bet SELinux would block apache/PHP from executing that script by default. 

setenforce 0

 

  • 0
  On 13/08/2015 at 00:19, Nik L said:

This is the log:

[Wed Aug 12 16:29:34.574067 2015] [:error] [pid 3121] [client 192.168.0.5:52634] PHP Warning:  socket_sendto(): unable to write to socket [13]: Permission denied in /var/www/html/info.php on line 7

Hmmmm, what do I need to escalate for permission?

Thats from audit.log?  That doesn't look like its from SELinux.

What linux distro are you using?

  • 0

Eep, sorry!  Ubuntu actually comes with apparmor by default, which is similar to SELinux.

You should remove SELinux.. I'm not even sure why it allowed you to install it with apparmor.

Check and verify that apparmor is on:

sudo apparmor_status

 

If it is you can disable it with this I believe:

sudo /etc/init.d/apparmor stop

 

I'm more familiar with Red Hat based distros (like Cent).  Ubuntu is more than capable of doing what you need. It mostly comes down to your taste on which distro you pick.

  • 0

I prefer CentOS, its very stable and widely used for web servers.  I might be overlooking something silly here because I just don't have the same level of experience with Ubuntu. 

There are some key differences between CentOS and Ubuntu, such as SELinux vs Apparmor (or lack thereof in your case LOL).  I will warn you that SELinux is a MAJOR pain, but if security isn't going to be a big issue you can easily just turn it off.

I haven't messed with CentOS 7 yet,  being new to Linux, I would recommend CentOS 6 anyways as its better documented. 

 

EDIT: There is one more thing you could try.  Set your PHP script to be in the same user:group as apache and/or set permissions to 777. 

This topic is now closed to further replies.
  • Posts

    • I've got a basic black and white laser printer that's connected via USB and doesn't do wifi etc. I think I'm going to be just fine.
    • Edge 138 is out with AI-powered history search and other changes by Taras Buria Microsoft has released Edge 138, the latest major update for the browser. Version 138.0.3351.55 introduces some interesting changes and new features, such as AI-powered history search. There are also several bug fixes and security patches. For regular users, the biggest and most important change in Edge 138 is AI-powered history search. This feature allows you to find sites in your history using synonyms, phrases, or misspelled words. Microsoft uses an on-device model, which does not send your data anywhere. Note that this feature is rolling out gradually, which means it might take a few days or weeks to show up on your system. Another useful change is new performance notifications. Performance and Extensions Detector notifications may appear in the main menu when the browser detects performance dips to help users learn about available performance-optimization tools. Autofill settings received a new consent toggle, which allows Microsoft to improve the autofill capabilities by collecting field names as you browse. This only applies to field names, such as "First Name, "Email," etc. It does not send the data you enter or autofill to Microsoft. Other changes include the following: Use the Primary work profile as the default profile to open external links. With this feature, for Windows, Edge checks if the Primary Work Profile exists and makes it the default profile for opening external links if available. Microsoft 365 Copilot Chat Summarization in Microsoft Edge Context Menu. This feature helps users quickly unpack and ask questions about their open page. Copilot on the Microsoft Edge New Tab Page (NTP). Users may see suggested work and productivity-related Copilot prompts in their search box on the NTP page. Adding support for viewing Sensitivity labels applied to a Microsoft Information Protection (MIP) Protected PDF. Enterprise customers can view sensitivity labels applied to MIP protected PDF to be well informed of the data classification to enable them to handle such sensitive documents. And here is what was fixed: Fixed an issue that caused WebDriver automation to fail in Microsoft Edge versions 133 and later. Fixed an issue where re-enabled textarea elements remained non-editable. This issue affected activating a role assignment in Privileged Identity Management. Finally, Edge 138 patches six security vulnerabilities, three of which were Microsoft Edge-specific, and the remaining three originated from Chromium. You can find details about those fixes here. The next Microsoft Edge update, version 139, is expected in the week of August 7, 2025.
    • “Never trust any statistics that you didn't forge yourself.”
    • Per the linked article: "Based on testing performed by Microsoft in December 2024 using Geekbench 6 Multi-core score comparing a selection of Windows 10 PCs with Intel Core 6th, 8th, and 10th generation processors and Windows 11 PCs with Intel Core 12th and 13th generation processors." I get that this is just advertising and all, but damn, I can smell the BS all the way over here. How about benchmarking 10 vs 11 on that same 13th gen processor? Apples and oranges make a lovely fruit salad but a terrible comparison. I mean shoot, my Windows 10 PC running a Ryzen 7 is faster than a Core2Duo running Windows 7, so Windows 10 is clearly faster. 🙄
    • KB5060829 installed in a test VM and the option isn't even there under "Taskbar behaviours". Installed it on a second VM, same. Installed it on metal... same. Typical quality of Nadella's Microsoft. If i doesn't shrink the taskbar vertical height down as @seeprime is implying, what's the point?
  • Recent Achievements

    • Week One Done
      suprememobiles earned a badge
      Week One Done
    • Week One Done
      Marites earned a badge
      Week One Done
    • One Year In
      runge100 earned a badge
      One Year In
    • One Month Later
      runge100 earned a badge
      One Month Later
    • One Month Later
      jfam earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      562
    2. 2
      +FloatingFatMan
      177
    3. 3
      ATLien_0
      167
    4. 4
      Michael Scrip
      125
    5. 5
      Xenon
      121
  • Tell a friend

    Love Neowin? Tell a friend!