Re: ./EuGTK/GtkEngine.e to Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here's something that seems to work, but the nslookup takes too long to use it every time you click something. About a 5 second delay. Perhaps there's a faster way, or maybe this could be set up to be called by a timer to check periodically? I'll bet this is what Windows does. Any other ideas?

-------------------------------- 
export function inet_address()  
-------------------------------- 
object ip 
ifdef LINUX then 
	sequence tmp = temp_file(,"MYIP-") 
	if system_exec(sprintf("hostname -I > %s ",{tmp})) = 0 then 
		ip = read_lines(tmp) -- 192.168.0.163 
		if equal({""},ip) then  
			if system_exec(sprintf("hostname -i > %s ",{tmp})) = 0 then 
				ip = read_lines(tmp) -- 127.0.1.1 
				if equal({""},ip) then return 0  
				else return ip[1] end if 
			end if 
		else return ip[1] 
		end if 
	end if 
end ifdef 
return 0 
end function 
 
--------------------------------- 
export function networked() 
--------------------------------- 
return match("127.0",inet_address()) != 1 
end function 
 
--------------------------------- 
export function inet_connected() 
--------------------------------- 
object result 
ifdef LINUX then 
	sequence tmp = temp_file(,"NCSI-") 
	if system_exec(sprintf("nslookup www.msftncsi.com > %s ",{tmp})) = 0 then 
		result = read_lines(tmp) 
		for i  = 1 to length(result) do 
		 if match("www.msftncsi.com",result[i]) = 1 then return TRUE end if 
		end for 
	else 
		display("No internets!") 
	end if 
end ifdef 
return FALSE 
end function 
 

  "Server:\t\t127.0.1.1", 
  "Address:\t127.0.1.1#53", 
  "", 
  "Non-authoritative answer:", 
  "www.msftncsi.com\tcanonical name = www.msftncsi.com.edgesuite.net.", 
  "www.msftncsi.com.edgesuite.net\tcanonical name = a1961.g.akamai.net.", 
  "Name:\ta1961.g.akamai.net", 
  "Address: 23.218.156.105", 
  "Name:\ta1961.g.akamai.net", 
  "Address: 23.218.156.91", 
  "" 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu