summaryrefslogtreecommitdiffhomepage
path: root/device
diff options
context:
space:
mode:
Diffstat (limited to 'device')
-rw-r--r--device/conn_linux.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/device/conn_linux.go b/device/conn_linux.go
index ebbbe11..f74ad51 100644
--- a/device/conn_linux.go
+++ b/device/conn_linux.go
@@ -391,6 +391,11 @@ func create4(port uint16) (int, uint16, error) {
return FD_ERR, 0, err
}
+ sa, err := unix.Getsockname(fd)
+ if err == nil {
+ addr.Port = sa.(*unix.SockaddrInet4).Port
+ }
+
return fd, uint16(addr.Port), err
}
@@ -450,6 +455,11 @@ func create6(port uint16) (int, uint16, error) {
return FD_ERR, 0, err
}
+ sa, err := unix.Getsockname(fd)
+ if err == nil {
+ addr.Port = sa.(*unix.SockaddrInet6).Port
+ }
+
return fd, uint16(addr.Port), err
}