On_The_Edge

Send / receive data between computers

Feb 25th, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. -- send and receive messages/data between computers --
  2.  
  3. netCard2 = component.proxy(component.findComponent(findClass("NetworkCard_C"))[1]) -- assign network card on computer to netCard2
  4.  
  5. -- receiver --
  6. event.listen(netCard2)
  7. netCard2:open(1) -- port = 1
  8. local res = {event.pull(2)}  -- pull > pull sender
  9. local e = res[1]
  10. local s = res[2]
  11. print (res[5])
  12. netCard2:close(1)
  13. event.ignore(netCard2)
  14.  
  15. -- sender --
  16. event.listen(netCard1)
  17. netCard1:open(1) -- port = 1
  18. netCard1:send("CEB21B964F80158BE6AA4C8A34A4424A",1, "test")  -- "CEB21B964F80158BE6AA4C8A34A4424A" = receiver netcard adress
  19. netCard1:close(1)
  20. event.ignore(netCard1)
Add Comment
Please, Sign In to add comment