I have tried to "set the defaultNetworkInterface to 127.0.0.1", then accept connections on port 1234. The problem I am having is that when it opens the network socket, it is bound to "0.0.0.0" still.
Is there any way to make a socket listen to 127.0.0.1 only? The service I am writing should only be accessible from localhost (127.0.0.1).
Thanks!
defaultNetworkInterface does not work with 127.0.0.1
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: defaultNetworkInterface does not work with 127.0.0.1
I don't think it's possible to disable connections before they happen (defaultNetworkInterface does something else then you assume, and is only for when you have several possible connections, like wifi and ethernet cable at the same time). However, you can ignore people connecting from the wrong port, which is how standalone firewalls work. For example:
Code: Select all
on mouseUp
accept connections on port 1234 with message "gotConnected"
put the result --if port is already open or disallowed by the os, this fails with "Error binding socket"
end mouseUp
on gotConnected theIP
set the itemdelimiter to ":"
if item 1 of theIP <> "127.0.0.1" then
close socket theIP
else
--do stuff here
end if
end gotConnected
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode