Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = peripheral.wrap("side")
- local handle p.socket_create("host", port)
- p.socket_setAutoFlush(handle, true) -- saves you calling socket_flush(handle) after using socket_write()
- p.socket_write(handle, "SomeLine\n")
- local e, side, handle2, line = os.pullEvent()
- if e == "socket_connectionClosed" and handle == handle2 then
- print("Connection closed")
- return
- elseif e == "socket_line" and handle == handle2 then
- print("Line received: "..line)
- end
- p.socket_close(handle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement