lxi_discover(3)

πŸ“¦
version 1.22 Β· 4 versions
, in debian trixie, epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– lxi_discover(3) β€” C Library Functions πŸ’–

okay bestie, so you wanna know about lxi_discover? it's the "search for LXI devices on network" one, and honestly it's giving main character energy. it lives in the C Library Functions section, so pull up a chair and let's get into it ✨


✨ SYNOPSIS ✨

#include <lxi.h>

int lxi_discover(lxi_info_t *info, int timeout, lxi_discover_t type);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what does lxi_discover() actually do? it searches for LXI devices or services on the local network β€” using VXI-11 or mDNS/DNS-SD respectively. which discover type you get is decided like this, no cap:

typedef enum
{
    DISCOVER_VXI11,
    DISCOVER_MDNS
} lxi_discover_t;

during the discover operation, events and results get returned by callbacks that you register through the info structure. and that struct is literally:

typedef struct
{
    void (*broadcast)(char *address, char *interface);
    void (*device)(char *address, char *id);
    void (*service)(char *address, char *id, char *service, int port);
} lxi_info_t;

okay so the callbacks, one by one:

  • the broadcast callback fires whenever a new network interface is searched (DISCOVER_VXI11 only).
  • the device callback fires whenever a new LXI device is found (DISCOVER_VXI11 only).
  • the service callback fires whenever a new LXI service is found (DISCOVER_MDNS only).

and the timeout? it's in milliseconds, bestie. so plan accordingly 🫢


🌈 RETURN VALUE 🌈

when everything goes slay, lxi_discover() returns LXI_OK. if an error happened, it returns LXI_ERROR. that's it, that's the whole vibe check πŸ’…


πŸŽ€ EXAMPLE πŸŽ€

this example searches for LXI devices using VXI-11 and prints the ID and IP addresses of found devices. iconic behaviour, truly:

#include <stdio.h>
#include <lxi.h>

void broadcast(char *address, char *interface)
{
    printf("Broadcasting on interface %s\n", interface);
}

void device(char *address, char *id)
{
    printf(" Found %s on address %s\n", id, address);
}

int main()
{
    lxi_info_t info;

    // Initialize LXI library
    lxi_init();

    // Set up search information callbacks
    info.broadcast = &broadcast;
    info.device = &device;

    printf("Searching for LXI devices - please wait...\n");

    // Search for LXI devices, 1 second timeout
    lxi_discover(&info, 1000, DISCOVER_VXI11);

    return 0;
}

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! πŸ§šβ€β™€οΈβœ¨

this lil masterpiece is from liblxi 1.22, dated 2024-11-08 β€” go forth and discover some devices, you've got this πŸ’œπŸŒΈ

πŸ“¦ where this page comes from