geekcomputers / geekcomputers/Python
Python socket server not able to listen ESL LUA COMMAND
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 35.4k
- Fork
- 12.9k
- Merge medio
- 2h 37m
- PR unite (30g)
- 1
Descrizione
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 ")
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia confrontando l’handler Python SocketServer e la chiamata Lua ESL.ESLconnection, quindi traccia il flusso di connessione e invio/ricezione mostrato nell’issue. Riproduci il listener sulle porte localhost indicate e determina perché il comando Lua non consegna dati al server Python; il lavoro è completato quando il server riceve il comando e risponde come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua, python
- Ambito
- networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100