Advertisement
bueddl

server

Sep 21st, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.63 KB | None | 0 0
  1. dofile("core")
  2.  
  3. local function server()
  4.     local sock = socket_create(AF_INET, SOCK_DGRAM, 0)
  5.  
  6.     if not sock:bind(inet_aton('212.201.26.99'), 80) then
  7.         perror('bind() failed')
  8.     end
  9.  
  10.     sock:listen()
  11.     print('Listening on ' .. inet_ntoa(sock:getip()) .. ':80')
  12.  
  13.     while true do
  14.         local peer = {}
  15.         local buffer = sock:recv_from(peer)
  16.         print('[' .. inet_ntoa(peer.network_address) .. ':' .. tostring(peer.transport_address) .. '] ' .. buffer)
  17.     end
  18.  
  19.     sock:close()
  20. end
  21.  
  22. setup_kernel()
  23. if not ifconfig('wlan0', '212.201.26.99') then
  24.     perror('ifconfig() failed')
  25. end
  26. process_create_named(server, 'server')
  27. dumpif()
  28. sched()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement