Skip to content

.socket() allows creation of more sockets than available #93

@anecdata

Description

@anecdata

socket.socket() correctly fails with RuntimeError: Failed to allocate socket. after creating all available sockets (4 for 5100S, 8 for 5500):

socks = []
while True:
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    socks.append(s)
    print(f"{s} {s.sendto(b'\xFF', (HOST, PORT))}")
    time.sleep(1)

socket.socket() will create sockets forever:

socks = []
while True:
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    socks.append(s)
    print(f"{s}")
    time.sleep(1)

On native wifi implementations, the latter example will fail with RuntimeError: Out of sockets after creating all available sockets.

The library could flag the error at creation time, rather than at time of (attempted) use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions