From ComputerCraft Wiki
Jump to: navigation, search

Grid Redstone.png  Function rednet.send
Allows a computer / turtle with an attached modem to send a message intended for a system with a specific ID (compare rednet.broadcast(), which aims to target everything in range). At least one such modem must first be "opened" before sending is possible. Assuming the target was in range and also had a correctly opened modem, it may then use rednet.receive() to collect the message.

Most data types can be sent, but functions / coroutines are converted to nil. In the past tables were also converted to nil, and required the use of textutils.serialize() to transmit - they can now be sent directly (exact build which changed things is unknown, but CC 1.53 works and 1.5 does not).

Messages are transmitted on a channel number equal to the target system's ID, with a suggested "reply" channel equal to the sending system's ID. Be aware that if other users are in range of your wireless network, or cabled into your wired network, knowing / guessing your target ID number will allow them to manually open that channel on their own systems in order to receive your messages. As of ComputerCraft 1.6, all rednet messages are additionally sent on channel 65533 (allowing the repeat script to easily detect them).

ComputerCraft 1.6 also introduces "protocol" - simple string names indicating what the message is about. Receiving systems may filter messages according to their protocols, thereby automatically ignoring incoming messages which don't specify an identical string. It's also possible to lookup which systems in the area are interested in certain protocols, hence making it easier to determine where given messages should be sent in the first place.
Syntax rednet.send(number receiverID, any message, [string protocol])
Returns boolean success code. True if a message has been sent (note - "sent", as opposed to "received" or even "was receivable"), false if not.
Part of ComputerCraft
API rednet


Grid paper.png  Example
Sends a message to the system with the ID of 22 (assuming a modem is attached and open).

Grid paper.png  Example
Sends a message to the system with the ID of 22, specifying a protocol of "TestMessages".

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