Difference between revisions of "Rednet.host"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with "{{lowercase}} {{Function |name=rednet.host |args={{type|string}} protocol, {{type|string}} hostname |returns=Nothing |api=rednet |addon=ComputerCraft |desc=Introduced by Compu...")
 
m (Navigation template)
 
Line 6: Line 6:
 
|api=rednet
 
|api=rednet
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Introduced by ComputerCraft 1.6, registers the system as "hosting" the desired protocol under the specified name. If a [[rednet.lookup|rednet lookup]] is performed for that protocol (and maybe name) on the same network, it'll automatically respond automatically via a background process, hence providing the remote system with its ID number.<br><br>
+
|desc=Introduced by ComputerCraft 1.6, registers the system as "hosting" the desired [[Rednet (API)#Protocols|protocol]] under the specified name. If a [[rednet.lookup|rednet lookup]] is performed for that protocol (and maybe name) on the same network, the registered system will automatically respond via a [[rednet.run|background process]], hence providing the system performing the lookup with its ID number.<br><br>
  
 
Multiple computers may not register themselves on the same network as having the same names against the same protocols, and the title "localhost" is specifically reserved. They may, however, share names as long as their hosted protocols are different, or if they only join a given network after "registering" themselves before doing so (eg while offline or part of a different network).<br><br>
 
Multiple computers may not register themselves on the same network as having the same names against the same protocols, and the title "localhost" is specifically reserved. They may, however, share names as long as their hosted protocols are different, or if they only join a given network after "registering" themselves before doing so (eg while offline or part of a different network).<br><br>
Line 13: Line 13:
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Registers the system as using the protocol "futonFolderComs" under the hostname "futonFolderServer". It'll respond to lookup requests such as that in the example code for [[rednet.lookup|rednet.lookup()]] until such time as rednet is closed, the name is unregistered (via [[rednet.unhost|rednet.unhost()]]), or the system is rebooted.
+
|desc=Registers the system as using the protocol "futonFolderComs" under the hostname "futonFolderServer". It'll respond to lookup requests (such as the example code for [[rednet.lookup|rednet.lookup()]]) until such time as rednet is closed, the name is unregistered (via [[rednet.unhost|rednet.unhost()]]), or the system is rebooted.
 
|code= rednet.open("top")
 
|code= rednet.open("top")
 
   
 
   
Line 19: Line 19:
 
}}
 
}}
 
}}
 
}}
 +
 +
{{RednetAPIFunctions}}
  
 
[[Category:API_Functions]]
 
[[Category:API_Functions]]

Latest revision as of 06:33, 6 June 2014


Grid Redstone.png  Function rednet.host
Introduced by ComputerCraft 1.6, registers the system as "hosting" the desired protocol under the specified name. If a rednet lookup is performed for that protocol (and maybe name) on the same network, the registered system will automatically respond via a background process, hence providing the system performing the lookup with its ID number.

Multiple computers may not register themselves on the same network as having the same names against the same protocols, and the title "localhost" is specifically reserved. They may, however, share names as long as their hosted protocols are different, or if they only join a given network after "registering" themselves before doing so (eg while offline or part of a different network).

See also: rednet.lookup(), rednet.unhost()
Syntax rednet.host(string protocol, string hostname)
Returns Nothing
Part of ComputerCraft
API rednet

Examples

Grid paper.png  Example
Registers the system as using the protocol "futonFolderComs" under the hostname "futonFolderServer". It'll respond to lookup requests (such as the example code for rednet.lookup()) until such time as rednet is closed, the name is unregistered (via rednet.unhost()), or the system is rebooted.
Code
rednet.open("top")

rednet.host("futonFolderComs","futonFolderServer")


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