This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Agent Silence's profile picture

How to protocols work in rednet?

Started by Agent Silence, 05 January 2015 - 04:16 AM
Agent Silence #1
Posted 05 January 2015 - 05:16 AM
Im rewriting the rednet api and im confused on how rednet handles protocols. There is no protocol found in modem.transmit for me so im a little confused
Lyqyd #2
Posted 05 January 2015 - 05:23 AM
It goes in the packet structure rednet uses, under the key "sProtocol". Take a look through the rednet API code and you should see how it's used.
Bomb Bloke #3
Posted 05 January 2015 - 06:16 AM
As a basic outline, rednet.send takes your message, the protocol, and one or two other bits of info, and bungs them in a table. That table then gets sent via modem.transmit, and the receiving computer repackages it as a rednet event at the other end (within rednet.run, which runs in parallel with the shell on all systems whether you ask for it or not - including those which don't have modems connected at all).

Prior to CC 1.6, there's no table encapsulation - the message just gets modem.transmit'd more or less as-is, and rednet.run thus has a slightly more simplistic job.
Agent Silence #4
Posted 05 January 2015 - 06:30 AM
Alright, so as I interpreted, it sends a table? Thank you! That helps me a lot