xpasetfd(3)

πŸ“¦
version 2.1.20 Β· 2 versions
  • 2.1.20 Β· debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2.1.20 Β· fedora 43, fedora 44
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– XPASetFd β€” the xpasetfd(3) glow-up πŸ’–

okay bestie, settle in, because this is the xpasetfd(3) page from the SAORD Documentation crew and it is lowkey a whole vibe. it lives in the xpa.h cinematic universe, so go peek at xpa(n) when you're done here. 🫢


✨ NAME ✨

XPASetFd β€” send data from stdin to one or more XPA servers πŸ’…


🌸 SYNOPSIS 🌸

#include <xpa.h>

int XPASetFd(XPA xpa,
             char *template, char *paramlist, char *mode,
             int fd, char **names, char **messages, int n)

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: XPASetFd() reads data from a standard I/O fd and ships it off to one or more XPA servers whose class:name identifier matches the template you gave it. it's giving courier but make it ✨interprocess communication✨.

A template shaped like "class1:name1" gets sent to the XPA name server, and that server hands back a list of at most n matching XPA servers. then we open a connection to each one of them, and the paramlist string gets passed to the server right as the data transfer request kicks off. if you handed an XPA struct to the call, the persistent connections get updated (as described above, iykyk). if you didn't, then we're making temporary connections to the servers, and those get closed the moment the call finishes. gone. ghosted. πŸ’€

Then XPASetFd() does its thing: it reads bytes from the fd you specified until EOF, and sends all those bytes to the XPA servers. the final parameter n is the max number of servers we're gonna contact. a string with the class:name and ip:port of each server comes back in the names array. and if any given server returned an error, that error message gets stashed in the matching element of the messages array. πŸŽ€

NB: if you specify them, the names and messages arrays must be of size n or greater. no cap. size them right or suffer.

The return value is the actual number of servers that got processed. so that number is literally the count of valid entries in your names and messages arrays, and you can use it to loop through them. if names and/or messages is NULL, then no information gets passed back in that array. simple as. 🌈

The mode string looks like this:

"key1=value1,key2=value2,..."

and these keywords are the ones it recognizes, bestie:

  • ack β€” value: true/false, default: true β€” if false, don't wait for ack from server (after callback completes)
  • verify β€” value: true/false, default: false β€” send buf from XPASet[Fd] to stdout

The ack keyword is so useful when you don't wanna sit around waiting for the server to finish. like, if a lot of processing needs to happen on the data you passed, or when the success of the server operation genuinely does not matter to the client. main character energy: send it and move on. πŸ’…βœ¨

πŸ“ Example πŸ“

#include <xpa.h>

#define NXPA 10
int  i, got;
int fd;
char *names[NXPA];
char *messages[NXPA];
fd = open(...);
got = XPASetFd(NULL, "ds9", "fits", NULL, fd, names, messages, NXPA);
for(i=0; i<got; i++){
  if( messages[i] != NULL ){
    /* error processing */
    fprintf(stderr, "ERROR: %s (%s)\n", messages[i], names[i]);
  }
  if( names[i] )
    free(names[i]);
  if( messages[i] )
    free(messages[i]);
}

πŸ‘‘ SEE ALSO πŸ‘‘

See xpa(n) for a list of XPA help pages 🧚


and that's the whole page, bestie β€” version 2.1.15, dated July 23, 2013. iconic, timeless, a lil vintage. mwah πŸ’–πŸŽ€πŸ¦‹