NET_Simulat...solutionLoss(3)

πŸ“¦
version 3.2.0 Β· 2 versions
, in fedora 43, fedora 44

✨ NET_Simulat...solutionLoss(3) ✨

okay bestie, buckle up, we're diving into the SDL_net3 FUNCTIONS section and this one is a whole mood πŸ’…


πŸŽ€ NAME πŸŽ€

NET_SimulateAddressResolutionLoss β€” the function that lets you enable simulated address resolution failures, aka you get to make your network be messy on purpose, no cap πŸ’€


🌸 SYNOPSIS 🌸

#include <SDL3_net/SDL_net.h>

void NET_SimulateAddressResolutionLoss(int percent_loss);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜•

A lot of the time, testing a networked app on your own dev machine β€” which lowkey might have a wired connection to a fast, reliable network service β€” just won't expose the bugs that show up when networks intermittently fail irl. You know, when the wifi is flakey and firewalls get in the way. The way that real life is just chaos and your code has never been vibe checked by it 🫠

This function lets you tell the library to pretend that some percentage of address resolutions will fail. it's giving "manufactured chaos, on purpose, for science" 🧚

The higher the percentage, the more resolutions will fail and/or take longer for resolution to complete. more percentage = more pain, basically ✨

Setting this to zero (which is the default) will disable the simulation entirely. Setting it to 100 means _everything_ fails unconditionally. At what percent the system merely borders on unusable is left as an exercise to the app developer 😭 (that's you. it's you. good luck bestie 🫢)

This is intended for debugging purposes β€” to simulate real-world conditions that are various degrees of terrible.

πŸ’€ fr fr: you probably should _not_ call this in production code, where you'll likely see real failures anyhow. like, the real world will do this to you for free, you don't need to help it.

πŸ’– FUNCTION PARAMETERS πŸ’–

  • percent_loss β€” a number between 0 and 100. Higher means more failures. Zero to disable. that's it, that's the whole parameter, she's simple but she's powerful πŸ‘‘

πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this function from any thread. multitasking queen behavior, we love to see it πŸ’…βœ¨


🌈 AVAILABILITY 🌈

This function is available since SDL_net 3.0.0. vintage but make it iconic πŸ’œ


and that's the whole page bestie, you ate that πŸ“ stay flakey out there πŸ’–

SDL_net 3.2.0 β€” mwah, xoxo, go break your own network on purpose πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from