aboutsummaryrefslogtreecommitdiffstats
path: root/net/net.go
diff options
context:
space:
mode:
Diffstat (limited to 'net/net.go')
-rw-r--r--net/net.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/net/net.go b/net/net.go
new file mode 100644
index 0000000..13a1891
--- /dev/null
+++ b/net/net.go
@@ -0,0 +1,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()
+}