socket state retrieval

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
sebi
Posts: 48
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

socket state retrieval

Post by sebi » Sat Mar 28, 2020 1:12 am

Code: Select all

>>> import socket
>>> s = socket.socket()
>>> s
<socket state=0 timeout=-1 incoming=0 off=0>
>>>
How can I retrieve state from s to test its value?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: socket state retrieval

Post by jimmo » Sun Apr 05, 2020 5:55 am

sebi wrote:
Sat Mar 28, 2020 1:12 am
How can I retrieve state from s to test its value?
Short of parsing the output (via dupterm to stringio), there isn't a way.

What are you trying to do? Why do you need the state.

User avatar
sebi
Posts: 48
Joined: Tue Mar 29, 2016 9:36 pm
Location: France

Re: socket state retrieval

Post by sebi » Sun Apr 05, 2020 10:51 am

I am connected to the internet via GPRS as I am running MicroPython on an A9G board.
Depending on the signal, the connection can be lost and I wanted to check the state of a socket in case of a disconnection.
But I found other ways to do this that do not involve parsing the output of socket.
Thank you very much for your answer!

Post Reply