'How to run python commands from flutter using tcp socket
Im trying to send commands to a python script from flutter using tcp sockets. In python Im using the pyzmq library.
Python:
import time
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5556")
while True:
# Wait for next request from client
print('Listening...')
message = socket.recv()
print("Received request: %s" % message)
# Do some 'work'
time.sleep(1)
# Send reply back to client
socket.send(b"World")
I then send messages to the python receiver using flutter but nothing is getting received or printed out in python. Simplified code below:
import 'dart:async';
import 'dart:convert';
import 'dart:io';
socket = await Socket.connect('localhost', 5556);
socket.add(utf8.encode('hello'));
How can I get this working?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
