geekcomputers / geekcomputers/Python

Python socket server not able to listen ESL LUA COMMAND

未关闭
#319 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
35.4k
派生
12.9k
平均合并
2 小时 37 分钟
30 天内合并 PR
1

描述

I have created 1 python server which listens on port eg 1234 and lua scripts connects to it . Connection is establishing but not able to send any data to python server. it works well if tried with simple tcp python client .

python server :
"""

import SocketServer
import esl

    class ESLRequestHandler(SocketServer.BaseRequestHandler):
        def setup(self):
            print self.client_address, 'connected!'

            fd = self.request.fileno()
        print fd

        con = esl.ESLconnection(fd)
        print 'Connected: ', con.connected()
        if con.connected():

            info = con.getInfo()

            uuid = info.getHeader("unique-id")
            print uuid
            con.execute("answer", "", uuid)
            con.execute("playback", "/ram/swimp.raw", uuid);

# server host is a tuple ('host', port)
server = SocketServer.ThreadingTCPServer(('localhost', 1234), ESLRequestHandler)
server.serve_forever()



"""
# first of all import the socket library
import socket

# next create a socket object
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Socket successfully created"

# reserve a port on your computer in our
# case it is 12345 but it can be anything
port = 1

# Next bind to the port
# we have not typed any ip in the ip field
# instead we have inputted an empty string
# this makes the server listen to requests
# coming from other computers on the network
s.bind(('127.0.0.1', port))
print "socket binded to %s" %(port)

# put the socket into listening mode
s.listen(5)
print "socket is listening"

# a forever loop until we interrupt it or
# an error occurs

   # Establish connection with client.
c, addr = s.accept()
print 'Got connection from', addr

   # send a thank you message to the client.
   #c.send('Thank you for connecting')


while True:
   d=c.recv(1024)
   print
   print d
   if d == "Status":
       c.send("Hey client")
   elif d == "c":
       c.send("letter c")
   elif d == "e":
       c.close()
   else :
       c.send("no data found")
   # Close the connection with the client
   #c.close()

Lua ESl script :
enter code here

#!/usr/local/bin/lua
require("ESL")

--local command = arg[1];
--table.remove(arg, 1);
--local args = table.concat(arg, " ");

local con = ESL.ESLconnection("localhost", "1234", "ClueCon")

--while con:connected() do

--end

con:send("event plain HEARTBEAT ");
local a = con:recvEvent()
print(a)
--con:sendRecv("event plain HEARTBEAT ")

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先比较 Python SocketServer 处理程序和 Lua 的 ESL.ESLconnection 调用,然后跟踪 issue 中所示的连接及发送/接收流程。在指定的 localhost 端口上复现 listener,并确定 Lua 命令为何无法向 Python 服务器传递数据;当服务器收到命令并按预期响应时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua, python
领域
networking
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。