• 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

    • OK, I guess that explains why they made it a full build update rather than a CU. Full build updates happen to Dev only about twice a year. Last one was in late March.
    • Google Chrome's new AI summarizes store reviews for you by Pradeep Viswanathan We frequently encounter various e-commerce websites while Browse online. Before placing an order, it’s common to look up reviews on Google to verify the site's legitimacy and product quality. Now, Google aims to streamline this process directly through the Chrome browser. For users in the US, Google Chrome now offers store reviews to improve your online shopping experience. Google is using Google Shopping data and other popular review websites to offer helpful insights. Here's how this feature works: When you visit an e-commerce website on Google Chrome, you can click the icon to the left of the web address. Google Chrome will then display an AI-generated summary of reviews. The summary will have details about customer service, product quality, shipping, pricing, and returns. On a related note, Google today announced the expansion of AI Mode to Google Search users in the UK. AI Mode is Google's AI-powered search experience, similar to Microsoft Bing's Copilot Search. While it may not be helpful for simple queries like asking for the weather or navigation queries, it will be helpful for more complex, multi-part questions and follow-ups. Google's AI Mode is built on a custom version of the Gemini 2.5 model, Google's flagship multi-modal AI model. The Google team wrote the following regarding the new AI Mode in Google Search: The new AI Mode will appear as a tab on the Google Search results page and is also available on mobile in the Google app for Android and iOS.
    • It was a matter of time. Anthropic must've been bleeding a lot of money with it.
    • OBS Studio 31.1.2 by Razvan Serea OBS Studio is software designed for capturing, compositing, encoding, recording, and streaming video content, efficiently. It is the re-write of the widely used Open Broadcaster Software, to allow even more features and multi-platform support. OBS Studio supports multiple sources, including media files, games, web pages, application windows, webcams, your desktop, microphone and more. OBS Studio Features: High performance real time video/audio capturing and mixing, with unlimited scenes you can switch between seamlessly via custom transitions. Live streaming to Twitch, YouTube, Periscope, Mixer, GoodGame, DailyMotion, Hitbox, VK and any other RTMP server Filters for video sources such as image masking, color correction, chroma/color keying, and more. x264, H.264 and AAC for your live streams and video recordings Intel Quick Sync Video (QSV) and NVIDIA NVENC support Intuitive audio mixer with per-source filters such as noise gate, noise suppression, and gain. Take full control with VST plugin support. GPU-based game capture for high performance game streaming Unlimited number of scenes and sources Number of different and customizable transitions for when you switch between scenes Hotkeys for almost any action such as start or stop your stream or recording, push-to-talk, fast mute of any audio source, show or hide any video source, switch between scenes,and much more Live preview of any changes on your scenes and sources using Studio Mode before pushing them to your stream where your viewers will see those changes DirectShow capture device support (webcams, capture cards, etc) Powerful and easy to use configuration options. Add new Sources, duplicate existing ones, and adjust their properties effortlessly. Streamlined Settings panel for quickly configuring your broadcasts and recordings. Switch between different profiles with ease. Light and dark themes available to fit your environment. …and many other features. For free. At all. OBS Studio 31.1.2 hotfix changes: Fixed an issue in OBS Studio 31.1.0 and 31.1.1 causing Multitrack Video to set the Maximum Video Tracks to 10 if the user had set it to "Auto" [dsaedtler] Fixed an issue in OBS Studio 31.1.0 and 31.1.1 causing Browser Source hardware acceleration to fail in the Flatpak version [reitowo/tytan652] Fixed an issue in OBS Studio 31.1.0 and 31.1.1 where progress bars were styled incorrectly [Warchamp7] Fixed an issue in OBS Studio 31.1.0 and 31.1.1 where spacing around scrollbars was incorrect [Warchamp7] Fixed an issue in OBS Studio 31.1.0 and 31.1.1 where Decklink Output did not work [CyBeRoni] Fixed a freeze in OBS Studio 31.1.0 and 31.1.1 on Linux when using PipeWire capture with explicit sync [YaLTeR] Fixed an issue where Video Capture Devices on Linux could unexpectedly stop capturing video [JiangXsong] Fixed an issue with PipeWire capture on Linux where video filters could cause gamma shift [tytan652] This was done by reverting a fix for white-tinted PipeWire captures in 10-bit or 16-bit color formats, so that issue will return for now. Download: OBS Studio 31.1.2 | Portable | ARM64 | ~200.0 MB (Open Source) View: OBS Studio Homepage | Other Operating Systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Sandboxie Plus 1.16.2 / Classic 5.71.2 by Razvan Serea Run programs in a sandbox to prevent malware from making permanent changes to your PC. Sandboxie allows you to run your browser, or any other program, so that all changes that result from the usage are kept in a sandbox environment, which can then be deleted later. Sandboxie is a sandbox-based isolation software for 32- and 64-bit Windows NT-based operating systems. It is being developed by David Xanatos since it became open source, before that it was developed by Sophos (which acquired it from Invincea, which acquired it earlier from the original author Ronen Tzur). It creates a sandbox-like isolated operating environment in which applications can be run or installed without permanently modifying the local or mapped drive. An isolated virtual environment allows controlled testing of untrusted programs and web surfing. Sandboxie is available in two flavors Plus and Classic. Both have the same core components, this means they have the same level of security and compatibility. What's different is the user interface the Plus build has a modern Qt based UI which supports all new features that have been added since the project went open source. The Classic build has the old no longer developed MFC based UI, hence it lacks support for modern features, these features can however still be used when manually configured in the Sandboxie.ini. Sandboxie Plus 1.16.2 / Classic 5.71.2 changelog: Added added toggleable INI key validation to "Edit ini Section" #4915 (thanks offhub) added toggleable per-key tooltip support #4928 (thanks offhub) added option to use the new Qt Windows 11 style on SandMan #4927 (thanks LumitoLuma) Changed ImBox no longer updates container file timestamps when accessing an encrypted box volume Fixed fixed Windows 11 24H2 build 26100.4770 causes Firefox Portable 140.0.4 / 141.0 to stop responding upon starting it sandboxed #4920 fixed leak of encrypted sandbox key during password change (backported hardened ImBox from MajorPrivacy) CVE-2025-54422 fixed Firefox Nightly sandbox hook errors Removed removed obsolete Bullguard Internet Security template removed obsolete Bsecure CloudCare template removed obsolete CyberPatrol template Download: Sandboxie Plus (64-bit) | 23.6 MB (Open Source) Download: Sandboxie Classic (64-bit) | 3.0 MB Links: Sandboxie Website | GitHub | ARM64 | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Dedicated
      ataho31016 earned a badge
      Dedicated
    • First Post
      Gladiattore earned a badge
      First Post
    • Reacting Well
      Gladiattore earned a badge
      Reacting Well
    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      652
    2. 2
      ATLien_0
      261
    3. 3
      Xenon
      165
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      107
  • Tell a friend

    Love Neowin? Tell a friend!