CLIENT_PORT = {} io.write("Set a server port: ") SERVER_PORT = tonumber(io.read()) print("Server port has been set to: "..SERVER_PORT) local modem = peripheral.find("modem") modem.open(SERVER_PORT) function pingLoc() io.write("Select a computer to ping: ") local num1 = tonumber(io.read()) modem.transmit(num1, SERVER_PORT, "pingLoc") event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message") print(message) end function list() for data in ipairs(CLIENT_PORT) do print("ID "..data) end end function newConnection() event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message") if message == "connectMessage" then table.insert(CLIENT_PORT, replyChannel, replyChannel) modem.transmit(replyChannel, SERVER_PORT, "connectSuccess") print("New connection from "..replyChannel) end end function userInput() command = io.read() end while true do parallel.waitForAny(newConnection, userInput) if command == "loc" then pingLoc() end if command == "list" then list() end end --event, modemSide, senderChannel, replyChannel, message, distance = os.pullEvent("modem_message") --if message == "connectMessage" then --print("Connection detected from "..replyChannel) --modem.transmit(replyChannel, SERVER_PORT, "connectSuccess") --end