This post is bit heavy so let us start with a joke.
Long ago when there was an ad in Sun TV which
went like this:
"India tholai katchigalil muthal muraiyaga... putham puthiya thirai
padam Sun TV yil."
Another concept was the "Rajni vaaram" or "Vivek vaaaram" concept of
running related movies for
one week in KTV.
I want to spend some 3 days or so talking about lua.
Lua is a new programming language developed by Brazil I think and it
is Brazilian for moon.
That is why you find the crescent symbol in their websites.
Here is a nice sample:
-- -----------------------------------------------------------------------------
-- UDP sample: echo protocol client
-- LuaSocket sample files
-- Author: Diego Nehab
-- RCS ID: $Id: echoclnt.lua,v 1.10 2005/01/02 22:44:00 diego Exp $
-----------------------------------------------------------------------------
local socket = require("socket")
host = host or "localhost"
port = port or 1234
if arg then
host = arg[1] or host
port = arg[2] or port
end
host = socket.dns.toip(host)
udp = assert(socket.udp())
assert(udp:setpeername(host, port))
print("Using remote host '" ..host.. "' and port " .. port .. "...")
while 1 do
line = io.read()
if not line or line == "" then os.exit() end
assert(udp:send(line))
dgram = assert(udp:receive())
print(dgram)
end
Just copy paste this and use this server with it:
-----------------------------------------------------------------------------
-- UDP sample: echo protocol server
-- LuaSocket sample files
-- Author: Diego Nehab
-- RCS ID: $Id: echosrvr.lua,v 1.12 2005/11/22 08:33:29 diego Exp $
-----------------------------------------------------------------------------
local socket = require("socket")
host = host or "127.0.0.1"
port = port or 1234
if arg then
host = arg[1] or host
port = arg[2] or port
end
print("Binding to host '" ..host.. "' and port " ..port.. "...")
udp = assert(socket.udp())
assert(udp:setsockname(host, port))
assert(udp:settimeout(5))
ip, port = udp:getsockname()
assert(ip, port)
print("Waiting packets on " .. ip .. ":" .. port .. "...")
while 1 do
dgram, ip, port = udp:receivefrom()
if dgram then
print("Echoing '" .. dgram .. "' to " .. ip .. ":" .. port)
udp:sendto(dgram, ip, port)
else
print(ip)
end
end
Now you know what to do.
Is this post too long for LUG? ;)
I will analyze this program tomorrow. Since you guys have switched off already.
I shall teach lua in the next couple of days.
-Girish
Gayatri Hitech
web: http://gayatri-hitech.com
SpamCheetah Spam filter:
http://spam-cheetah.com
_______________________________________________
To unsubscribe, email [email protected] with
"unsubscribe <password> <address>"
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc