Search found 6 matches

by srinivasa rao pedada
Fri Oct 15, 2021 4:21 am
Forum: ESP8266 boards
Topic: socket.fileno() not available in esp8266, Please suggest some alternative
Replies: 1
Views: 22672

socket.fileno() not available in esp8266, Please suggest some alternative

class poller: # A simple utility class to wait for incoming data to be # read on a socket. def __init__(self): if "poll" in dir(select): self.use_poll = True self.poller = select.poll() else: self.use_poll = False self.targets = {} def add(self, target, socket=None): if not socket: socket = target....
by srinivasa rao pedada
Tue Sep 14, 2021 3:33 am
Forum: ESP32 boards
Topic: Difference between asyncio stream and synchronous stream for json output to a client
Replies: 2
Views: 1515

Re: Difference between asyncio stream and synchronous stream for json output to a client

got the error:

Code: Select all

asyncio.wait_for(sreader.readline(), self.timeout)
------> changed to

Code: Select all

asyncio.wait_for(sreader.read(2048), self.timeout)
. Now client is recieving json output immediately after closing the socket. Like you said its a timing issue, thank you sir.
by srinivasa rao pedada
Tue Sep 14, 2021 3:32 am
Forum: ESP32 boards
Topic: asyncio stream vs synchronous stream in socket communication with a react native app
Replies: 3
Views: 2046

Re: asyncio stream vs synchronous stream in socket communication with a react native app

got the error:

Code: Select all

asyncio.wait_for(sreader.readline(), self.timeout)
------> changed to

Code: Select all

asyncio.wait_for(sreader.read(2048), self.timeout)
. Now client is recieving json output immediately after closing the socket. Like you said its a timing issue, thank you sir
by srinivasa rao pedada
Tue Sep 14, 2021 1:54 am
Forum: ESP32 boards
Topic: asyncio stream vs synchronous stream in socket communication with a react native app
Replies: 3
Views: 2046

Re: asyncio stream vs synchronous stream in socket communication with a react native app

asyncio basic server example code: import usocket as socket import uasyncio as asyncio import uselect as select import ujson class Server: def __init__(self, host='0.0.0.0', port=80, backlog=5, timeout=10): self.host = host self.port = port self.backlog = backlog self.timeout = timeout async def ru...
by srinivasa rao pedada
Mon Sep 13, 2021 1:40 pm
Forum: ESP32 boards
Topic: Difference between asyncio stream and synchronous stream for json output to a client
Replies: 2
Views: 1515

Difference between asyncio stream and synchronous stream for json output to a client

response = { 'error': 'invalid request', 'status': 'retry' } synchronous side: conn.send('HTTP/1.1 200 OK\n') conn.send('Content-Type: application/json\n') conn.send('Connection: close\n\n') conn.sendall(ujson.dumps(response )) asyncio side: swriter.write(ujson.dumps(response )) await swriter.drain...
by srinivasa rao pedada
Mon Sep 13, 2021 7:18 am
Forum: ESP32 boards
Topic: asyncio stream vs synchronous stream in socket communication with a react native app
Replies: 3
Views: 2046

asyncio stream vs synchronous stream in socket communication with a react native app

Objective is esp32 running micropython acts as a server while android app acts as a client. Before asyncio stream I am able to communicate successfully, but after switching to asyncio i fail to do so, only android app to esp32 is sucessfull but app is failing to retrieve json output ad I even tried ...