getsockname()
- Returns the local address information associated to UDP socket.
- Note: UDP sockets are not bound to any address until the setsockname or the sendto method is called for the first time (in which case it is bound to an ephemeral port and the wild-card address).
Edit
| Parameter | Type | Required | Description |
|---|---|---|---|
| handle | int | + | Connection handle |
Edit
| Type | Description |
|---|---|
| string | Local address |
| string | Local port |
Edit
local network = require("network")
local handle = network.udp();
network.setpeername(handle, "8.8.8.8", "80")
local ip, _ = network.getsockname(handle)
print(ip)