summaryrefslogtreecommitdiff
path: root/rudp/connect.go
diff options
context:
space:
mode:
Diffstat (limited to 'rudp/connect.go')
-rw-r--r--rudp/connect.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/rudp/connect.go b/rudp/connect.go
new file mode 100644
index 0000000..548ab15
--- /dev/null
+++ b/rudp/connect.go
@@ -0,0 +1,18 @@
+package rudp
+
+import "net"
+
+type udpSrv struct {
+ net.Conn
+}
+
+func (us udpSrv) recvUDP() ([]byte, error) {
+ buf := make([]byte, maxUDPPktSize)
+ n, err := us.Read(buf)
+ return buf[:n], err
+}
+
+// Connect returns a Conn connected to conn.
+func Connect(conn net.Conn) *Conn {
+ return newConn(udpSrv{conn}, PeerIDSrv, PeerIDNil)
+}