Sample Script: TLuaSocket--Construct a new socket object socket = TLuaSocket() iPortNumber = 8080 --Open a TCP socket iRet = socket:OpenTCP(iPortNumber) --If OpenTCP returned a 0 (boolean FALSE) then the open failed if iRet==0 then print("Cannot open port "..iPortNumber.." Error code:"..GetLastError()) else --Read some data (max 1024 bytes) from the socket iReadSize = 1024 data = socket:Read(iReadSize) --Print the content if iReadSize > 0 then print("Data received from server:\n\n") print(data) else print("No data received from server") end end socket:Close() | |||
Topic 9734: Send Feedback. Download a PDF of this online book from the first topic in the table of contents. Print this topic. |