sock_open(3z)

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

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

okay bestie, we're in the z88dk Programmer's Manual and this is the page for sock_open β€” yes the (3z) is part of the whole vibe, it's a section 3 library call, we love a library call 🫢


✨ NAME ✨

sock_open β€” open an active network connection

like, you're the one reaching out. you're sliding into the server's DMs. active energy, no listening around here πŸ’…


🌸 SYNOPSIS 🌸

#include <net/socket.h>

SOCKET *sock_open(ipaddr_t ipdest, tcpport_t dport,
                   void (*handler)(), char proto);

that's the whole handshake, bestie. four things and you're online ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so sock_open() does two things at once, main character behavior fr fr:

  1. it creates a socket descriptor
  2. it attempts to establish a connection to the port dport on the host ipdest, using the protocol proto

and listen β€” right now, the only protocols that are actually supported are prot_UDP and prot_TCP. that's it. those two. anything else and we're not doing this today πŸ™ˆ

the handler parameter specifies a handler that gets called whenever the connection changes state or new data arrives. that's what it does. ngl though, it's of archaic interest only β€” which is the manual's polite way of saying "it's a relic, it's giving museum piece, don't build your whole personality around it" πŸ’€


πŸŽ€ RETURN VALUE πŸŽ€

sock_open() returns a socket descriptor. slay. that's the win condition πŸ‘‘

but if you specify a protocol that isn't supported? the carry flag gets set and the return value is EPROTONOSUPPORT. so like, not a vibe. check your proto, bestie, because that's the whole error report you're getting 😭


🌈 SEE ALSO 🌈

  • sock_listen(3z)

the sibling page. the other half of the duo. if sock_open is sliding into DMs, sock_listen is waiting by the phone πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

Dominic Morris <dom@jb.man.ac.uk>

thank you king, we are obsessed 🫢


and that's the whole page, periodt πŸ’…

this lil rewrite was born from the z88dk Programmer's Manual, and the original page is dated 18 February 2000 β€” yeah, a Y2K baby, iconic behavior honestly ⭐

okay ily, go open a socket, be safe, and don't forget the carry flag πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from