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

Rednet localhost

Started by MrObsidy, 04 May 2019 - 02:48 PM
MrObsidy #1
Posted 04 May 2019 - 04:48 PM
Hello! Currently I am writing a display manager software (Think X11) that should consists of a server (who runs the actual programs) and some clients (which runs the I/O, you can have multiple clients per server, so you could have headless systems (=non-advanced computers that run "advanced" software)).
Now since most users (including me) tend to run programs locally, I want to have the possibility to run a tserver and tclient on the same machine and connect the tclient to the local tserver.
Issue is, that I want to send the I/O information and the frame information via rednet (so I can have a display server and multiple clients.)

So this brings up two questions for me:

1) Can I rednet-connect to localhost and if so
2) can I do so without having a modem installed (Needing a modem to connect to localhost is pointless, let's face it.)?

Hope somebody can answer this.

EDIT: By testing, I found out that rednet.send(os.getComputerID(), <message>) works just as it should AND that this works regardless if a modem is opened.
Meaning this works even if no modem is open or attached:

rednet.send(os.getComputerID(), "Testmsg")

local sender, msg = rednet.receive()

print(msg)
will output
 Testmsg 
just as expected.
Edited on 04 May 2019 - 03:11 PM
Lupus590 #2
Posted 04 May 2019 - 09:54 PM
For no modem I think you will need to create a fake rednet/modem API.

With a modem (wired or wireless) you should be able to send a message to your own computer id (although I seem to think that rednet will filter this out so you may want to check that).

Personally I would just have the server act as a local client while also doing the server stuff.
Luca_S #3
Posted 04 May 2019 - 10:49 PM
For no modem I think you will need to create a fake rednet/modem API.

With a modem (wired or wireless) you should be able to send a message to your own computer id (although I seem to think that rednet will filter this out so you may want to check that).

Personally I would just have the server act as a local client while also doing the server stuff.

If only rednet is used then sending messages to the current computer doesn't require a modem. It is first checked if the message goes to the computer it originates from and only if it isn't it will check if there are open modems: https://github.com/S.&#46;&#46;/rednet.lua#L85
Edited on 05 May 2019 - 04:50 AM