• 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

    • OneDrive for Mac now lets you sync files to removable drives by Taras Buria If you use OneDrive on Mac and often work with external drives (a common sight among Mac users where internal storage is not upgradeable), Microsoft has some good news for you: the OneDrive client for macOS now supports removable drives, allowing you to sync files to external disks, both non-removable and removable. Microsoft introduced external drive support in OneDrive for Mac at the beginning of 2025. However, the initial rollout was limited to drives that macOS detects as non-removable. The company received plenty of feedback from users regarding this change, and it is now addressing the inability to sync files to removable drives. External drive support in OneDrive works the same way as syncing files to internal storage. If you unplug your drive, say, a portable SSD, OneDrive will stop syncing and notify you with an error message (there is a short delay for drives that sporadically disconnect). To resume sync, reconnect your drive and restart OneDrive. If you want to sync OneDrive to an external drive, your drive should be formatted for APFS (Apple File System) and protected by FileVault (read-only, network, and quarantined drives are not supported). Also, you need macOS version 15.0 or newer and OneDrive version 25.097 or newer. For now, external drive support is only available for insiders, but a wider rollout is coming soon. Finally, Microsoft adds that external drive support does not allow moving drives between devices. Therefore, you must set up OneDrive sync again every time you connect your drive to a new Mac. You can read more about external drive support in OneDrive for Mac in a post on the official Tech Community website. In other OneDrive news, check out our recently published guide, which details how to change OneDrive folder colors for extra personalization.
    • I'm here for it! Bill Pullman & Rick Moranis Returning For New ‘Spaceballs’; Keke Palmer Also Set https://deadline.com/2025/06/spaceballs-2-casts-rick-moranis-bill-pullman-keke-palmer-1236431204/ It's gonna be epic! 
    • Lipstick on a data-hungry pig...
    • I really feel like we need a 3rd good phone OS option to compete with Google and Apple.
    • After 40 years we asked what the fans want...... and are making this movie anyway! 
  • Recent Achievements

    • One Month Later
      POR2GAL4EVER earned a badge
      One Month Later
    • One Year In
      Orpheus13 earned a badge
      One Year In
    • One Month Later
      Orpheus13 earned a badge
      One Month Later
    • Week One Done
      Orpheus13 earned a badge
      Week One Done
    • Week One Done
      serfegyed earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      536
    2. 2
      ATLien_0
      260
    3. 3
      +FloatingFatMan
      203
    4. 4
      +Edouard
      168
    5. 5
      Xenon
      124
  • Tell a friend

    Love Neowin? Tell a friend!