UDP send/receive using PacketSender

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 681
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

UDP send/receive using PacketSender

Post by Grovkillen » Sat Mar 28, 2020 2:17 pm

I have a server that is broadcasting it's whereabouts using UDP on a given port. I want my clients to just listen for this broadcast and once received it should configure itself to connect to this IP.

I found the application https://packetsender.com/documentation and it turned out that it work great, if you know how to use the command line switches....

Using the portable version I can send UDP messages using this syntax:

Code: Select all

packetsender -b <port> -u -A <ip>.255 <port> "<data>"
packetsender -b 1234 -u -A 192.168.1.255 1234 "send this as ASCII, -b is the outgoing UDP port, -u is protocol UDP, -A parse data as ASCII, the last three parameters are the IP (send to 255 to send to all), port once again, and last the message with " ... "
If you want to listen to UDP messages... well that's were I was kinda lost but here's a trick... use the -w switch to have the application "wait" after it has broadcasted a message. If you're not interested in having the client send any message, just listen you still need to send a dummy message. Like so:

Code: Select all

packetsender -b <port> -u -w 60000 -A <any ip> <port> "<null>"
packetsender -b 1234 -u -w 60000 -A 127.0.0.1 1234 "bogus"
The command line will now output messages for the next 60 000 ms (one minute)... you can pipe these to the clipboard or a text file for further scripting.
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 681
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: UDP send/receive using PacketSender

Post by Grovkillen » Sun Mar 29, 2020 7:36 pm

Ooooh, I'm in love with the Swiss File Knife app. It can do the same as the PacketSender (and resides in a single exe) but so much more: https://sourceforge.net/projects/swissfileknife/

To send UDP:

Code: Select all

sfk udpsend 192.168.1.255 12345 "message"
Where 12345 is the port...

To listen to UDP:

Code: Select all

sfk udpdump 12345
More commands are found here: http://stahlworks.com/dev/swiss-file-knife.html
Let>ME=%Script%

Running: 15.0.19b
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts