Datagram socket correct syntax

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

Datagram socket correct syntax

Post by ecflyer » Thu Oct 21, 2010 12:15 am

I am sending out a request to all possible computers on the network. Currently, I am using a loop that sends the message to each IP address, one at a time. I understand I should be able to use "open datagram socket to ????", but do not know how to write that out.

The computers at the other end receive the message and then send back a message to the originating computer. Is a datagram socket the best way to go for this? Can someone show me how to write out the code; i.e. "open datagram socket to socket ("192.168.0.1 - 255") with message. Don't know if I still have to send it out one IP address at a time or if the proper IP syntax is "192.0.0.0" or ??

Thanks,

E

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Datagram socket correct syntax

Post by mwieder » Thu Oct 21, 2010 4:42 pm

In general, sending a packet to address 255 (as in 192.168.0.255) is broadcast to all addresses in the subnet.

This might help:

http://lessons.runrev.com/spaces/lesson ... ng-sockets

ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

Re: Datagram socket correct syntax

Post by ecflyer » Thu Oct 21, 2010 10:19 pm

Thank you mwieder, I did get some extra ideas from the tutorial. Just to be clear on your answer, here is what I am using now:

Code: Select all

on scanIPRange pRange
     put 1 into x
     repeat 255
          put (pRange & "." & x) into tMasterIP
          probIP tMasterIP
          add 1 to x
     end repeat
end scanIPRange
probIP sends out the message "probing" to each socket. Instead, would I do this:

Code: Select all

on scanIPRange
     open socket to "192.168.0.255:1234"
     write "probing" to socket "192.168.0.255:1234"
end scanIPRange
and expect every computer in the 192.168.0.*** range that is listening on socket "1234" to receive a message?

I did not have any luck with the above code and need more details about how to send "probing" all at once to 192.168.0.1 - 192.168.0.255

Thanks

Eric

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Datagram socket correct syntax

Post by WaltBrown » Thu Oct 21, 2010 10:37 pm

Hi!
Did you try a UDP message? As in "open datagram socket"?
Walt
Walt Brown
Omnis traductor traditor

ecflyer
Posts: 24
Joined: Tue Oct 20, 2009 12:04 am

Re: Datagram socket correct syntax

Post by ecflyer » Thu Oct 21, 2010 11:06 pm

Hi Walt, I did change my open socket to open datagram socket with no success.

E

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Datagram socket correct syntax

Post by Mark » Fri Oct 22, 2010 11:38 am

ecflyer,

What script are you using on the recieving side?

Broadcasting to ...255 may not work (e.g. on my Macs). It is safer to use a repeat loop. I would also use

Code: Select all

repeat with x= 0 to 254 with messages
  -- do somehing
  wait 0 millisecs with messages
end repeat
This will give Rev some time to do management behind the scenes and it might help.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply