Skip to content

Encountering OSError -203 for sockets...no such error code found in errno #16951

Answered by shariltumin
haldark asked this question in ESP32
Discussion options

You must be logged in to vote

You only need to do the bind once. If the server.bind((host, port)) then your server is not ready to accept any connection.

We need to close opened client sockets to reclaim resources.

The example below will keep the client socket open until the client side closes the socket.

import socket

########## Server Class: BEGIN ############
class SlimServer(object):

    def __init__(self, host="0.0.0.0", port=80):
        # server
        self._server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self._server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self._server.bind((host, port))
        self._server.listen(1)

    def _client(self, cs):
        while True:
 …

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@haldark
Comment options

Comment options

You must be logged in to vote
1 reply
@haldark
Comment options

Comment options

You must be logged in to vote
3 replies
@haldark
Comment options

@shariltumin
Comment options

Answer selected by haldark
@haldark
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
ESP32
Labels
None yet
4 participants