Page 1 of 1

Datagram socket correct syntax

Posted: Thu Oct 21, 2010 12:15 am
by ecflyer
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

Re: Datagram socket correct syntax

Posted: Thu Oct 21, 2010 4:42 pm
by mwieder
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

Re: Datagram socket correct syntax

Posted: Thu Oct 21, 2010 10:19 pm
by ecflyer
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

Re: Datagram socket correct syntax

Posted: Thu Oct 21, 2010 10:37 pm
by WaltBrown
Hi!
Did you try a UDP message? As in "open datagram socket"?
Walt

Re: Datagram socket correct syntax

Posted: Thu Oct 21, 2010 11:06 pm
by ecflyer
Hi Walt, I did change my open socket to open datagram socket with no success.

E

Re: Datagram socket correct syntax

Posted: Fri Oct 22, 2010 11:38 am
by Mark
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