# `Linx.Netlink.Request`
[🔗](https://github.com/oshlabs/linx/blob/v0.2.0/lib/linx/netlink/request.ex#L1)

The synchronous request engine: send one netlink request and collect the
kernel's reply.

`talk/4` handles all three reply shapes uniformly:

  * an **acknowledgement** — a single `NLMSG_ERROR` with errno 0, returned by
    a request that carried `NLM_F_ACK`;
  * a **single reply** — one data message answering a non-dump request;
  * a **dump** — a multipart series of data messages (`NLM_F_MULTI`),
    terminated by `NLMSG_DONE`.

It allocates a fresh sequence number per request from the socket's counter,
and accepts only replies that echo it back — so a stale reply, or an
unsolicited multicast notification, cannot be mistaken for the answer.

The module is synchronous and holds no state of its own: a later connection
process can reuse the same logic to drive a socket it owns.

# `talk`

```elixir
@spec talk(Linx.Netlink.Socket.t(), 0..65535, non_neg_integer(), iodata()) ::
  {:ok, [Linx.Netlink.Message.t()]} | {:error, term()}
```

Sends a request and returns the kernel's reply.

`type` and `payload` are the message type and body. `flags` are extra
`nlmsghdr` flags — `NLM_F_ACK`, `NLM_F_DUMP`, and so on; `NLM_F_REQUEST` is
added automatically.

Returns `{:ok, messages}` with the data messages of the reply (an empty list
for a bare acknowledgement), or `{:error, reason}`. A kernel error is
`{:error, %Linx.Netlink.Error{}}`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
