lxi\_discover(3) C Library Functions lxi\_discover(3)

# [NAME](#NAME)

lxi\_discover - search for LXI devices on network

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;lxi.h&gt;**

**int lxi\_discover(lxi\_info\_t \*info, int timeout, lxi\_discover\_t type);**

# [DESCRIPTION](#DESCRIPTION)

The **lxi\_discover()** function searches for LXI devices or services on the local network using VXI-11 or mDNS/DNS-SD respectively. Which discover *type* is used is defined as follows:

```
typedef enum
{


    DISCOVER_VXI11,


    DISCOVER_MDNS
} lxi_discover_t;
```

During the discover operation events and results are returned by callbacks registered via the *info* structure, defined as follows:

```
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;
```

The *broadcast* callback is called whenever a new network interface is searched (DISCOVER\_VXI11 only).

The *device* callback is called whenever a new LXI device is found (DISCOVER\_VXI11 only).

The *service* callback is called whenever a new LXI service is found (DISCOVER\_MDNS only).

The *timeout* is in milliseconds.

# [RETURN VALUE](#RETURN_VALUE)

Upon successful completion **lxi\_discover()** returns **LXI\_OK** , or **LXI\_ERROR** if an error occurred.

# [EXAMPLE](#EXAMPLE)

The following example searches for LXI devices using VXI-11 and prints the ID and IP addresses of found devices:

```
#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](#SEE_ALSO)

[**lxi\_discover\_if**(3)](/man/enterprise-packages/liblxi/lxi_discover_if.3) [**lxi\_init**(3)](/man/enterprise-packages/liblxi/lxi_init.3) [**lxi\_open**(3)](/man/enterprise-packages/liblxi/lxi_open.3), [**lxi\_close**(3)](/man/enterprise-packages/liblxi/lxi_close.3) [**lxi\_receive**(3)](/man/enterprise-packages/liblxi/lxi_receive.3), [**lxi\_disconnect**(3)](/man/enterprise-packages/liblxi/lxi_disconnect.3),

2024-11-08 liblxi 1.22

---

Document: lxi_discover(3) from liblxi 1.22-r3 (Chainguard OS)
Source: https://github.com/lxi-tools/liblxi
