sock_write(3z)

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

πŸ’Œ sock_write(3z) β€” bestie's guide to yeeting bytes into a socket

okay so this is a page from the z88dk Programmer's Manual, and it's literally about writing bytes to a network socket. no cap. let's get into it πŸ’…


🌸 NAME 🌸

sock_write β€” write bytes to a network socket

yeah that's it, that's the whole job. she writes bytes. she's an icon, she's a legend, and she is the moment ✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <net/socket.h>

size_t sock_write(SOCKET *s, void *dp , size_t len);

(and yes bestie, that space before the comma in void *dp , size_t len is exactly how it's written in the original, we do not touch the sacred text πŸ™ˆ)


πŸ¦‹ DESCRIPTION πŸ¦‹

So first thing first, the parameter s? That's a descriptor to an open socket. And not just any socket β€” one that you made with sock_open(3z) or sock_listen(3z). So like, she needs to already be in the group chat before you start sending her messages, ykwim? 🫢

The sock_write() function writes a stream of bytes to the open socket specified by s. The data of length len is taken from address dp β€” and heads up, dp should be in the lower 16k of the memory map. that's a whole thing, don't fight it, just put your data down there πŸ’€


⭐ RETURN VALUE ⭐

sock_write() returns the number of bytes written to the socket. simple. slay.

BUT β€” and this is the part where we pay attention β€” if an illegal socket is supplied, the carry flag will be set and the return value will be EPROTONOSUPPORT. so like, if you handed her a fake ID, she's not just gonna quietly ignore it, she's gonna set a whole carry flag about it. dramatic? yes. valid? also yes 😭


🌈 SEE ALSO 🌈

  • sock_putc(3z)
  • sock_puts(3z)

(the little sibling functions, love them for her πŸ’–)


πŸ‘‘ AUTHOR πŸ‘‘

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


okay that's the whole page bestie, you ate, go write some bytes πŸ“βœ¨

this was page sock_write(3z) from the z88dk Programmer's Manual, dated 18 February 2000 β€” yeah she's an elder but she still serves πŸ’…πŸ¦‹

πŸ“¦ where this page comes from