File: conn_windows.go

package info (click to toggle)
golang-github-insomniacslk-dhcp 0.0~git20250417.5f8cf70-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 1,096 kB
  • sloc: makefile: 3
file content (21 lines) | stat: -rw-r--r-- 539 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//go:build windows

package server4

import (
	"fmt"
	"net"
)

// NewIPv4UDPConn returns an UDPv4 connection bound to the IP and port provider
func NewIPv4UDPConn(iface string, addr *net.UDPAddr) (*net.UDPConn, error) {
	connection, err := net.ListenPacket("udp4", addr.String())
	if err != nil {
		return nil, fmt.Errorf("We cannot listen on %s and port %d: %v", addr.IP, addr.Port, err)
	}
	udpConn, ok := connection.(*net.UDPConn)
	if !ok {
		return nil, fmt.Errorf("The connection is not of the proper type")
	}
	return udpConn, nil
}