Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
danielrama30

Problem with the server, modem.send() and modem.broadcast

Question

Hello everyone.

I have a problem with the server rack the commands mentioned in the title of the thread.

I have to send a message from the server to a computer.....but the problem is that he receives messages from other computers but not send them. I tried to use programs and single commands but still not work.

I wrote this on the server:

component.modem.broadcast("111, "test") or component.modem.send({computer address}, 111, "test")

And this on the computer:

=event.pull("modem_message")

I used the relay to realize that it is the server doesn't send messages because it doesn't blink. (Not sure I wrote correctly, I'm not english.)

Every method I try doesn't work. Nobody else has had this problem? Can someone help me?

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi.

If you use a Server make sure that you configured the rack correctly. As you see in the screenshot below a server with a network card has two connections. One for the Component network and one for the Network Card itself, while a server without network card only has one connection. Also make sure that the cable is connected to the correct side.

 

 

Unbenannt.png

Link to post
Share on other sites
  • 0

In the computer:

--Setting libraries
local component = require("component")
local term = require("term")
local event = require("event")
local modem = component.modem

--Program code

modem.open(111)

term.clear()
print(">")
term.setCursor(2,1)
input = io.read()

if input == "server.status" then
  modem.send("address of the server", 123, input)
  os.sleep(2)
  local _,_,_,_,_,status = event.pull("modem")
  print("Server status: " .. status)
else
  print("Illegal command")
end

In the server:

--Setting libraries
local component = require("component")
local term = require("term")
local event = require("event")
local modem = component.modem

--Program code
modem.open(123)

while true do
  local _,_,remoteNetwork,_,_,input = event.pull("modem_message")
  print("Command received: " .. input)
  
  if input == "server.status" then
    modem.send(remoteNetwork, 111, "Online")
  else
    modem.send(remoteNetwork, 111, " ")
  end
end
    

 I tried with modem.send() and modem.broadcast() but nothing changes.

Link to post
Share on other sites
  • 0

I believe I see the problem.. You are sleeping past the responses from the server.. Try this out. It has some comments to try and explain...

-- # Setting libraries
local component = require("component")
local term = require("term")
local event = require("event")
local modem = component.modem

-- # Program code

modem.open(111)

term.clear()
print(">")
term.setCursor(2,1)
input = io.read()

if input == "server.status" then
  modem.send("address of the server", 123, input)
  -- # os.sleep(2) // HERE. We sleep beyond the response of the server, thus waiting forever.
  -- # event.pull is essentially coroutine.yield, which will wait for a loose match of an event id. i.e "modem" will match "modem_message"
  local _,_,_,_,_,status = event.pull("modem") -- # halt until any modem* event. This, ideally, should be "modem_massege"
  print("Server status: " .. status) -- we must have seen an event that at least started with the string "modem".
else
  print("Illegal command")
end

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.