how to listen on UDP ports and start as applescript?

Hello,

I have a windows programm in my network that is able to send IP-telegrams ( text messages) via UDP Port 7000 to a specified ip-address.

I would love to make OS X, which is also in this network, listen to that port and run an apple script, according to the content, that will be sent in that telegram. Also I want to send answers using that udp port after having received a message.

I am totally lost how to set up the “port listening” and reaktion to it?? Apple script alone does not support that i believe. but maybe some pearl/shell script?

Can anyone help me?

Thank you!

I did not see anything terribly useful while searching http://osaxen.com/ for UDP…

You might look at the “UNIX” program nc. I know it can send and receive UDP packets, but I am not sure of the best way to use it from AppleScript. Since UDP is not connection oriented, it is hard for nc to know when UDP-based communications are finished (and hence when it should exit). Also, I do not think the normal do shell script way of invoking command line programs will work if you need to do two-way communications with the program.

How about TCP connections (which I also can choose).
Is it easer there to listen and react to specific messages/telegrams?

thanks

Sure, nc can do TCP also. But I am still not sure how you could establish two-way communication with nc from AppleScript, do shell script only seems to enable reading from the program(s) that are run, not writing.
:frowning: Sorry.

There are a couple of OSAXen that can do TCP, but the only one that is labeled as being for Mac OS X (XNet) doesn’t seem to have server capabilities. There is a more complete one that looks like it does server stuff too (TCP/IP Scripting Addition), but it is labeled as Mac OS 9. It might be workable under Mac OS X, I do not know what the “X”/“9” badges on osaxen.com really imply.

We label them X, 9 or 9/X. You can bet that a 9 for doing TCP/IP stuff definitely won’t work in OS X.

Although I haven’t personally used Jean-Baptiste LE STANG’s XNet, its dictionary certainly seems to imply that it might work here. You can open and close sockets, read and write sockets. I suspect that a note to him (use the link on the download page for XNet) will clarify things. I’ve had good luck with others of his osaxen.