NET_Status(3type)

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

πŸ’– NET_Status β€” the tri-state bestie for async stuff πŸ’–

ok so this is a page from the SDL_net3 DATATYPES manual, and the star of the show is NET_Status. it's a lil enum, it's iconic, it's giving "did it work tho?" energy. let's get into it ✨


🌸 NAME 🌸

NET_Status β€” a tri-state for asynchronous operations. three states, no cap. πŸ‘‘


✨ SYNOPSIS ✨

#include <SDL3_net/SDL_net.h>

typedef enum NET_Status
{
    NET_FAILURE = -1,  /**< Async operation complete, result was failure. */
    NET_WAITING = 0,   /**< Async operation is still in progress, check again later. */
    NET_SUCCESS = 1    /**< Async operation complete, result was success. */
} NET_Status;

look at that enum. immaculate. the comments are even in there, we do not touch those, they are part of the vibe. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

ok so bestie, here's the tea: a LOT of stuff in SDL_net is asynchronous. like, it literally cannot finish until data travels across a network at some mysterious murky point in the future. we don't know when. nobody knows when. it's giving ~the unknown~ 🌫️

this includes:

  • sending data over a stream socket πŸ“¨
  • resolving a hostname πŸ”
  • connecting to a remote system πŸ”Œ
  • and other tasks, iykyk

the library never blocks on tasks that take time to complete. like, never. with ONE exception: functions named Wait, which exist purely to do nothing but block until a task completes. that's literally their whole job. main character energy but make it "I will sit here and wait." 😭

and here's the slay part: functions that are attempting to do something that might block, or that are querying the status of a task that's already in-progress, will return a NET_Status. so your app can peek and go "oh! it finished!" and also "oh! here's how it went." 🫢

so real quick, the three states:

  • NET_FAILURE = -1 β€” async operation complete, and the result was a failure. it did NOT eat. πŸ’€
  • NET_WAITING = 0 β€” async operation is still in progress, so check again later. she's still cooking. πŸ“
  • NET_SUCCESS = 1 β€” async operation complete, and the result was a success. ATE. no crumbs. πŸ”₯
ngl the whole point is: you poll, you vibe check the status, you keep it moving. never block unless you chose to call a Wait function. periodt.

🌈 AVAILABILITY 🌈

this enum has been available since SDL_net 3.0.0. she's been here. she's a veteran. πŸ’œ


and that's the whole page bestie, ty for reading, stan NET_Status, mwah πŸŽ€

this was brought to you by the SDL_net manual, version SDL_net 3.2.0 β€” go forth and check your statuses, queen βœ¨πŸ’…πŸ¦‹

πŸ“¦ where this page comes from