func initConn(t *testing.T, port int) *xudp.Connection { c := xudp.New(1400) c.Register(New(sent, recv, acked, lost, 60)) err := c.Open(port) if err != nil { t.Fatal(err) } return c }
func initConn(t *testing.T, port int) *xudp.Connection { c := xudp.New(1400) c.Register(New(0xBADBEEF)) err := c.Open(port) if err != nil { t.Fatal(err) } return c }
// initConn initializes our connection. func initConn(port int) *xudp.Connection { plugin = reliability.New(nil, nil, nil, nil, 30).(*reliability.Plugin) conn := xudp.New(1400) conn.Register(plugin) err := conn.Open(port) if err != nil { fmt.Fprintf(os.Stderr, "initConn: %v\n", err) os.Exit(1) } fmt.Printf("Listening on port %d...\n", port) return conn }
// NewOrderedConnection creates a new ordered connection. func NewOrderedConnection(mtu uint32) *OrderedConnection { c := new(OrderedConnection) c.Connection = xudp.New(mtu) c.recvCache = make(map[uint32]*Data) c.sendCache = make(map[uint32]*Data) c.Incoming = make(chan *Data) c.Register(reliability.New( func(seq uint32, addr net.Addr, data []byte) { c.sent(seq, addr, data) }, func(seq uint32, addr net.Addr, data []byte) { c.recv(seq, addr, data) }, func(seq uint32) { c.acked(seq) }, func(seq uint32) { c.lost(seq) }, 30, )) return c }