Socket:send(data)
Send all the data to the Socket. In blocking mode, the method can block if the length of the data is larger than the maximum allowed by the transport.
Parameters
data
A Buffer or a string
containing the data to be sent. If another type of variable is used, it is internaly converted to a string before sending.
Return value
Returns one of the following possible values :true
if the operation succedded, orfalse
if an error occured.- Task object to perform the operation asynchronously if the Socket is non-blocking, returning one of the previous values once finished.
Example
local net = require "net"
-- create a socket to www.google.com on port 80
local socket = net.Socket("www.google.com", 80)
if socket:connect() then
print("Connected to www.google.com !")
local sent = socket:send("GET / HTTP/1.1\r\nHost:www.google.com\r\n\r\n")
print("Bytes sent : "..sent)
end