Socket.canread readonly property



The Socket.canread gets the readability of a Socket after a net.select() call.

Example

local net = require "net" -- create the server listening Socket local server = net.Socket("127.0.0.1", 5000) -- array of clients Sockets local sockets = {server} if server:bind() and server:listen() then print("Server running on 127.0.0.1:5000") while true do if net.select(sockets) == false then error("Network error : "..net.error) break end -- if a new client connects, send the "Hello World !" message and close the Socket if server.canread then local client = server:accept() client:send("Hello World !") client:close() end end end