sock_dataready(3z)

πŸ“¦ version 1.10.1, in fedora 43, fedora 44

πŸ’– sock_dataready(3z) πŸ’–

okay bestie, pull up a chair, because we're talking about sock_dataready(3z) β€” a lil function from the z88dk Programmer's Manual that answers the most iconic question in all of networking: "is there mail for me??" πŸ“¬βœ¨


✨ NAME ✨

sock_dataready β€” test whether a network connection has incoming data πŸ¦‹


✨ SYNOPSIS ✨

#include <net/socket.h>

size_t sock_dataready(SOCKET *s);

✨ DESCRIPTION ✨

So the parameter s is a descriptor to an open socket β€” and not just any socket, a socket you made with sock_open(3z) or sock_listen(3z). πŸ’… like, it has to already exist, bestie, we're not manifesting sockets out of thin air.

The sock_dataready() function tests whether a socket has data waiting to be read by the user program. that's it. that's the whole job. it's giving receptionist checking if you have a package πŸ“¦ β€” it does not hand you the package, it just tells you one is there. so lowkey essential before you go reading, no cap.


✨ RETURN VALUE ✨

sock_dataready() returns the amount of data waiting in the input queue. πŸ”₯ so like, a number. the actual size of the pile of goodies sitting in the queue. zero means nothing's there, so don't go reading and act surprised, okay? 😭


✨ SEE ALSO ✨

  • sock_read(3z) β€” the one that actually takes the data, iykyk 🫢

✨ AUTHOR ✨

Dominic Morris <dom@jb.man.ac.uk> β€” the icon, the legend, the moment πŸ‘‘


mwah πŸ’‹ that's the whole page! z88dk Programmer's Manual, dated 18 February 2000 β€” yeah bestie, this one is vintage vintage, a true Y2K relic πŸŽ€βœ¨ go forth and check your sockets before you read from them, periodt πŸ’…

πŸ“¦ where this page comes from