geekcomputers / geekcomputers/Python
Python socket server not able to listen ESL LUA COMMAND
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 35.4k
- Forks
- 12.9k
- Avg merge
- 2h 37m
- Merged PRs (30d)
- 1
Description
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 ")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the Python SocketServer handler and the Lua ESL.ESLconnection call, then trace the connection and send/receive flow shown in the issue. Reproduce the listener on the stated localhost ports and determine why the Lua command does not deliver data to the Python server; done means the server receives the command and responds as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100