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

Problem communicating 4 computers

Started by Jonnhycraft, 27 May 2014 - 11:39 PM
Jonnhycraft #1
Posted 28 May 2014 - 01:39 AM
Hi.

I've a problem to communicate between 4 computers.

Here is the code on the "server" :


local modem = peripheral.wrap("top")
modem.open(100)
local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
print("I just received a message from: "..senderChannel)
print("I should apparently reply on: "..replyChannel)
print("The modem receiving this is located on the "..modemSide.." side")
print("The message was: "..message)
print("The sender is: "..senderDistance.." blocks away from me.")

And the code on the 3 clients


sleep(5);
local modem = peripheral.wrap("top")
modem_id=101 # 102 on the 2nd client and 103 on the 3rd client
modem.transmit(100, modem_id, "Hello world!")

When i quit and open the game, the 4 computers start automaticaly their programs (via startup)… and I receive only the message from the modem_id 103.
Does I did a mistake ?
Is there a limitation "1 channel to etablish a connection only between 2 computers, no more" ?

Regards
Edited on 27 May 2014 - 11:41 PM
apemanzilla #2
Posted 28 May 2014 - 01:44 AM
You're only pulling for events once. Try wrapping the server code in a while loop.
Jonnhycraft #3
Posted 28 May 2014 - 02:20 AM
That's true. I'm correcting my code. Thank you
Lyqyd #4
Posted 28 May 2014 - 04:06 AM
Moved to Ask a Pro.