From ComputerCraft Wiki
Jump to: navigation, search

Grid Redstone.png  Function rednet.lookup
Introduced by ComputerCraft 1.6, searches the local rednet network for systems "hosting" the desired protocol and returns any computer IDs that respond as "registered" against it. If a hostname is specified, only one ID will be returned (assuming an exact match is found).

Lookups are broadcasted with a specified protocol of "dns". Replies are sent back to the sender's ID number with the same protocol.

See also:, rednet.unhost()
Syntax rednet.lookup(string protocol, [string hostname])
Returns number ID1, number ID2, ...
Part of ComputerCraft
API rednet


Grid paper.png  Example
Attempts to determine the ID of a remote system that has registered itself as using the protocol "futonFolderComs" under the hostname "futonFolderServer".

local futonServerID = rednet.lookup("futonFolderComs","futonFolderServer")

if futonServerID then
	print("Found the server on channel "..futonServerID.."!")
	print("Failed to locate the futon server.")

Grid paper.png  Example
Attempts to determine the IDs of all remote systems that have registered themselves as using the protocol "futonFolderComs".

local futonServerID = {rednet.lookup("futonFolderComs")}

for i=1,#futonServerID do
	print("Found a server on channel "..futonServerID[i].."!")

Grid disk.png Rednet API Functions - rednet.close - rednet.send - rednet.broadcast - rednet.receive - rednet.isOpen - - rednet.unhost - rednet.lookup