[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-dev] cinvoke/lua - server socket
From: |
luc1an0 |
Subject: |
[cinvoke-dev] cinvoke/lua - server socket |
Date: |
Wed, 25 Oct 2006 11:55:45 +0200 |
User-agent: |
Internet Messaging Program (IMP) 3.2.5 |
I found a source for a C socket server :
http://www.cs.rpi.edu/courses/sysprog/sockets/server.c
I want to "translate" it on lua application. I wrote some lines just in order to
create socket. But i don't know how can i use a structure sockadrr in a lua
programme.
My lua source :
#!/usr/local/bin/lua
require("cinvoke_lua")
libc = clibrary.new("libc.so.6")
address = cstructure.new(Cint,"sa_family", Cchar(14), "adr")
sock = libc:get_function(Cint , "socket", Cint, Cint, Cint)
lstn = libc:get_function(Cint,"listen", Cint,cinv.array(Cchar), Cint)
bnd = libc:get_function(Cint, "bind", Cint,cinv.array(Cchar), Cint)
acpt = libc:get_function(Cint, "accept",Cint,cinv.array(Cchar), Cint)
address.sa_family = 1
address.adr = "127.0.0.1"
nsock = sock(2,1,0)
bnd(nsock,address,128)
lstn(nsock, address, 1)
print ("Listenning...")
while 1 do
acpt(nsock,address,1)
end
I don't want to look for error for a first time.
- [cinvoke-dev] cinvoke/lua - server socket,
luc1an0 <=