How do I close a socket correctly? #13625
Unanswered
sishari
asked this question in
RP2040 / Pico
Replies: 1 comment 1 reply
-
Minimal example which should work:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have with pico a socket problem.
A socket server is running on the pico.
I can connect with a client a maximum of 4 times.
After that, no connection with a client is possible.
How do I properly close a socket on the Pico?
I tried both:
1.
asyncio.start_server(serve, "0.0.0.0", 10001)
async def serve(reader, writer):
await asyncio.sleep(3)
writer.close()
writer.wait_closed()
server1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server1.bind(('0.0.0.0', 10001))
client,addr = server1.accept()
await asyncio.sleep(3)
client.close()
Beta Was this translation helpful? Give feedback.
All reactions