aboutsummaryrefslogtreecommitdiffstats
path: root/net/net.go
blob: 13a189168d91cb97044fd0f945a82907c925959c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package net

import (
	"fmt"
	std_net "net"

	"git.samanthony.xyz/hose/util"
)

func AcceptConnection(network string, port uint16) (std_net.Conn, error) {
	laddr := std_net.JoinHostPort("", fmt.Sprintf("%d", port))
	ln, err := std_net.Listen(network, laddr)
	if err != nil {
		return nil, err
	}
	defer ln.Close()
	util.Logf("listening on %s", laddr)
	return ln.Accept()
}