Jump to: navigation, search

Mihini/socket

SOCKET

TCP example:- Variables

local sched = require 'sched'
local socket = require 'socket'

Main function

local function main()
  local tcpSocket= socket.bind("ip-address",8090)
    while true do
       data=tcpSocket:receive('*a')
       print(data)
    end
end

UDP Socket

Variables

local sched = require 'sched'
local socket = require 'socket'

Main function

local function main()
  local tcpSocket= socket.bind("ip-address",8090)
   while true do
     data=tcpSocket:receive('*a')
     print(data)
  end
end