DNET_EOF(3)

πŸ“¦ version 2.65build2, in ubuntu jammy

πŸ’– DNET_EOF(3) πŸ’–

okay bestie, welcome to the Library Functions Manual section, we're talking dnet_eof today and honestly? it's giving ✨vibe check for your socket✨ πŸ¦‹


🌸 NAME 🌸

dnet_eof β€” is your DECnet socket at End of File? asking for a friend πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <netdnet/dn.h>
#include <netdnet/dnetdb.h>

int dnet_eof (int fd)

like it's SO simple, one little function, one little int, periodt 🫢


✨ DESCRIPTION ✨

so here's the tea, bestie β˜•

dnet_eof returns 0 if the socket is not at end-of-file. that's the "we're still good, keep reading" energy 🌈

it will return -1 otherwise, and errno gets set accordingly. and if the socket is at EOF? errno gets set to ENOTCONN. no cap, that's the whole thing πŸ’€

okay important part: dnet_eof is only supported on Linux 2.4.0 or later. on earlier kernels it will always return -1 and errno will be set to EINVAL. so if you're on some ancient kernel, that's your answer and it's not the one you wanted 😭

🧚 EXAMPLE 🧚

here's a lil primitive server example that literally just prints out anything sent to it from the remote side. main character behaviour fr fr πŸ‘‘

#include <sys/types.h>
#include <netdnet/dn.h>
#include <netdnet/dnetdb.h>
#include <stdio.h>

int main(int argc, char **argv)
{
   int insock, readnum;
   char ibuf[1024];

   // Wait for something to happen (or check to see if it already has)
    insock = dnet_daemon(0, "GROT", 0, 0);

    if (insock > -1)
    {
        dnet_accept(insock, 0, 0, NULL);
        while (!dnet_eof(insock))
        {
            readnum=read(insock,ibuf,sizeof(ibuf));
            fprintf(stderr, "%-*s\n", readnum, ibuf);
        }
        close(insock);
    }

}

see how it loops while !dnet_eof(insock)? that's the whole trick bestie, we stay in the loop until EOF says we're done πŸŽ€βœ¨


πŸ’œ SEE ALSO πŸ’œ

go read those too, iykyk πŸ“šπŸ’…


πŸ’– and that's the page!! DECnet functions, July 28, 1998, DNET_EOF(3) πŸ’–

okay ily, go check your sockets, mwah 🫢🌸

πŸ“¦ where this page comes from