defaultNetworkInterface does not work with 127.0.0.1

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Kyle W
Posts: 4
Joined: Wed May 02, 2012 4:11 am

defaultNetworkInterface does not work with 127.0.0.1

Post by Kyle W » Wed May 02, 2012 11:01 pm

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!

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: defaultNetworkInterface does not work with 127.0.0.1

Post by BvG » Fri May 04, 2012 1:56 pm

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

Post Reply