qt - Sockets comunication between QTScript and Python -


i'm trying communicate external python script c++ program allows qt-scripting. goal partially control c++ program (using qtscript api functions) python code.

i know how create basic socket server/client in python:

#server code  import socket  server = socket.socket() server.bind (("localhost", 8080)) server.listen(10) client, client_adress = server.accept()  while true:     message= cliente.recv(1024)     if message== "quit":         break     print "received:", message     client.send(message)  print "goodby" cliente.close() server.close() 

...

#client code  import socket client = socket.socket() client.connect(("localhost", 8080))  while true:     message = raw_input(">" )     client.send(message)     if message == "quit":         break  print "goodby" 

but can't found info on how in qtscript (no javascript experience), know there qtcpsocket class, i'm not sure start snipet python ones have there question, not useful clues me... , there samples can't make work.

whats better, client or server in python? can find qtscript example?

thanks in advanced!

it sounds have qtscript (javascript) interpreter running inside qt c++ program. , want python client able send commands it. simplest (but not secure!) way have python client connect either basic tcp or http post, send executable javascript program across, , have c++ program execute internally.

this way python side quite trivial. c++ side, you'd first create qtcpserver , when receives data, read of , pass string qscriptengine::evaluate(). how use qtcpserver, see here: http://doc.qt.io/qt-5/qtnetwork-fortuneserver-example.html


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -