geekcomputers / geekcomputers/Python
Python socket server not able to listen ESL LUA COMMAND
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 35.4k
- Forks
- 12.9k
- Merge medio
- 2 h 37 min
- PR fusionados (30 d)
- 1
Descripción
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 ")
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza comparando el handler de Python SocketServer y la llamada Lua ESL.ESLconnection; después, sigue el flujo de conexión y de envío/recepción mostrado en el issue. Reproduce el listener en los puertos localhost indicados y determina por qué el comando Lua no entrega datos al servidor Python; la tarea estará completada cuando el servidor reciba el comando y responda como se espera.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- lua, python
- Área
- networking
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100