美文网首页
0730 - 杂记

0730 - 杂记

作者: 自由快挂 | 来源:发表于2017-07-30 20:46 被阅读15次

    win 工程配置

    很多时间浪费在项目配置里面,一个 x64 位的库配在 86 的工程设置里面,难怪一直 link 出错。

    还是自己的问题,经验尚浅啊。

    socket server

    用来本地测试的,基于 luvit 。 tcp-echo-server-simple.lua

    local net = require('net')
    
    local server = net.createServer(function(client)
      print("Client connected")
    
      -- Add some listenners for incoming connection
      client:on("error",function(err)
        print("Client read error: " .. err)
        client:close()
      end)
    
      client:on("data",function(data)
        print(data)
        client:write(data)
        client:write(data)
      end)
    
      client:on("end",function()
        print("Client disconnected")
      end)
    end)
    
    -- Add error listenner for server
    server:on('error',function(err)
      if err then error(err) end
    end)
    
    server:listen(1234, '127.0.0.1') -- or "server:listen(1234)"
    

    运行

    luvit tcp-echo-server-simple.lua
    

    相关文章

      网友评论

          本文标题:0730 - 杂记

          本文链接:https://www.haomeiwen.com/subject/tbmklxtx.html