Socket:close()

Closes the Socket and the bounded connection. The Socket should not be used anymore.

When the Socket is garbage collected, the close method is called automatically

Return value

Returns no value.

Example

-- Echo Server example local net = require "net" -- create the server listening Socket local server = net.Socket("127.0.0.1", 5000) -- not needed, socket.blocking is already set to true (default) server.blocking = true server:listen() local client = server:accept() print('Connected with ', client.ip) -- echo to the client the data just received while true do local data = client:recv() if data == false then -- client:close() not needed, will be called upon client garbage collection break end client:send(data) end