Search documentation of snmpkit

# SnmpKit.SnmpMgr.SocketManager (snmpkit v1.3.17)

Manages shared UDP sockets for SNMP operations.

Provides centralized socket lifecycle management with configurable buffer sizes and health monitoring. Eliminates the need for individual processes to manage their own sockets.

# Summary

## Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

get_buffer_stats(manager \\ __MODULE__)

Gets detailed UDP buffer utilization metrics.

get_port(manager \\ __MODULE__)

Gets the local port the socket is bound to.

get_socket(manager \\ __MODULE__)

Gets the shared UDP socket.

get_stats(manager \\ __MODULE__)

Gets socket statistics and health information.

health_check(manager \\ __MODULE__)

Checks if the socket is healthy and operational.

start_link(opts \\ [])

Starts the SocketManager GenServer.

# Functions

# child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# get_buffer_stats(manager \\ __MODULE__)

Gets detailed UDP buffer utilization metrics.

Returns buffer usage, queue lengths, and utilization percentages.

# get_port(manager \\ __MODULE__)

Gets the local port the socket is bound to.

# get_socket(manager \\ __MODULE__)

Gets the shared UDP socket.

Returns the socket reference that can be used for sending SNMP packets. The socket is configured with appropriate buffer sizes and options.

## Examples

    iex> socket = SnmpKit.SnmpMgr.SocketManager.get_socket()
    iex> :gen_udp.send(socket, {192, 168, 1, 1}, 161, packet)

# get_stats(manager \\ __MODULE__)

Gets socket statistics and health information.

Returns information about buffer usage, packet counts, and socket health metrics.

# health_check(manager \\ __MODULE__)

Checks if the socket is healthy and operational.

# start_link(opts \\ [])

Starts the SocketManager GenServer.

## Options

- `:buffer_size` - UDP receive buffer size in bytes (default: 4MB)
- `:port` - Local port to bind (default: 0 for OS assignment)
- `:name` - Process name (default: MODULE)