#πŸ”’ What's the best way to keep a UDP server active and waiting for data?

67 messages Β· Page 1 of 1 (latest)

alpine cipher
#

I have this UDP server, and I'd like to keep it active, but putting it in a permanent while loop doesn't feel right to me. I'm concerned it could lead to fork-bombs and extensive CPU usage. It's also blocking, which I don't like. Are there safer alternatives?

https://paste.pythondiscord.com/PL5A

I haven't asked ChatGPT yet, I've been trying to avoid it.

blazing escarpBOT
#

@alpine cipher

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

twin moon
elfin pelican
tacit gyro
#

why would there be fork bombs?

alpine cipher
tacit gyro
#

?

#

nothing about sockets makes your processes fork

twin moon
tacit gyro
#

that's...insane

twin moon
#

Shrug. Generalises to doing other things I guess. Anyway, it's not hard to limit the threads in play or something like that.

tacit gyro
#

at the very least a thread pool should be used

twin moon
#

or, since I'm lazy and low level, a semaphore

alpine cipher
twin moon
teal wind
#

!pypi lynkio

blazing escarpBOT
#

Lynk – Python only Realtime Server FrameworkHTTP + WebSockets + Database in one engine.No dependencies.

Released on <t:1773218999:D>.

tacit gyro
#

_handler() could use a match block – it's making unnecessary comparisons

alpine cipher
alpine cipher
tacit gyro
alpine cipher
tacit gyro
teal wind
alpine cipher
alpine cipher
alpine cipher
alpine cipher
teal wind
# alpine cipher I tried working with Nodejs, but its BigInt library was horrible.

Hmm am not familiar with nodejs, i did thought about what you said well the lynkio I built only supports TCP so base on the benefits of UDP for game streaming and more not because brower would change lynkio is a framework not for building only web apps you make it fit what you want,

I will make lynkio support protocol switching automatically

user would have to specify a particular protocol to use,

Building something like this isn't about just knowing how to code if you understand the architecture you can build it,

Explain if UDP is supported

device β†’ UDP packet β†’ server

I would make lynkio support UDP

alpine cipher
tacit gyro
#

that would involve UPnP, yes?

teal wind
tacit gyro
teal wind
tacit gyro
#

it lacks the standard pyproject.toml project manifest

#

I'm not sure recent versions of pip will even install this thing

#

and it contains non-standard requirements.txt files

teal wind
teal wind
tacit gyro
#

???

#

none of what you're saying makes sense

teal wind
tacit gyro
#

are you adding a pyproject.toml?

teal wind
tacit gyro
#

ok

#

the project also lacks any kind of a test suite

alpine cipher
# tacit gyro that would involve UPnP, yes?

As far as I've read, holepunching doesn't involve UPnP. UPnP requires other protocols, like http. UDP holepunching is basically, you send my server a UDP packet from your "server"'s address. Then my server responds on that same ip:port. The router assumes you want the data, because you just connected to me on that port.

tacit gyro
#

which I see as a red flag

teal wind
teal wind
tacit gyro
#

which part in particular?

teal wind
tacit gyro
#

I have, but how does that relate to the lack of a test suite?

teal wind
tacit gyro
#

it's easily one of the most arduous parts of any project, but a vital component nonetheless

teal wind
tacit gyro
teal wind
tacit gyro
#

I can't tell what the test coverage is

#

and as you mentioned, you need to automate the testing

teal wind
tacit gyro
#

I suggest you move them to a separate folder for easier collection with pytest

blazing escarpBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.