server.lua

#!/usr/bin/lua

local socket = require("socket")

host, port = "127.0.0.1", 9090

server = assert(socket.bind(host, port))
ack = "ack\n"

while true
do
    print("server: waiting for client connection ...")
    control = assert(server:accept())
    while true
    do
        command, status = control:receive()
        if status == "closed" then
           break
        end
        print(command)
        control:send(ack)       -- 注意:发送的数据必须要有结束符才能发送成功
    end

end

client.lua

#! /usr/bin/lua

local socket = require("socket")
host, port = "127.0.0.1", 9090

client = assert(socket.connect(host, port))

client:send("GET\n")

while true
do
    local s, status, partial = client:receive()
    print(s)
    if status == "closed" then
       break
    end

client:send("GET\n")
end

client:close()

最新文章

  1. SQL Server2014 SP2关键特性
  2. Tomcat服务器本地的搭建,以及在 IDEA软件下的配置,以及项目的测试运行(基于supermvc框架下的web)
  3. PHP读写大“二进制”文件,不必申请很大内存(fopen、fread、fwrite、fclose)
  4. Java学习笔记,前两章总结
  5. LeetCode——Reverse Integer(逆置一个整数)
  6. C#泛型简化代码量示例
  7. Qt工具知多少(一目了然)
  8. nagios监控linux设置
  9. 《RPM源码包的制作》RHEL6
  10. Bootstrap_排版_标题
  11. (一)CodeMirror - 基本应用
  12. [PCB设计] 3、用CAM350修改GERBER文件(删除某些部分)
  13. CAP 2.4版本发布,支持版本隔离特性
  14. TextField
  15. RS485 VS 20mA 电流环
  16. windows保存的文件传输到linux中格式转换
  17. ES6 promise学习笔记 -- 基本用法
  18. db2文件系统已满
  19. 虚拟机上不能使用CUDA
  20. linux c++环境

热门文章

  1. ruby----controller中简单的增删改 方法定义
  2. golang json反序列化
  3. 【leetcode-69】 x 的平方根
  4. PHP7 网络编程(六)Socket和IO多路复用【待】
  5. 复杂sql查询语句
  6. 【转载】 C#读写注册表
  7. 24.join算法/锁_1
  8. 新萌渗透测试入门DVWA 教程1:环境搭建
  9. ubuntu 中文变成小方框 口
  10. html去掉滑动条