// Connect connects to the server on conn
// and closes conn when the Peer disconnects
Connect connects to the server on conn
and closes conn when the Peer disconnects
// Connect connects to the server on conn // and closes conn when the Peer disconnects
func Connect(conn net.PacketConn, addr net.Addr) (*Peer, error) {
	srv := &Peer{Peer: rudp.Connect(conn, addr)}
	ack, err := srv.Send(rudp.Pkt{Data: []byte{0, 0}})
	if err != nil {
		return nil, err
	}
	select {
	case <-time.After(8 * time.Second):
		srv.SendDisco(0, true)
		srv.Close()
		return nil, ErrServerUnreachable
	case <-ack:
	}
	return srv, nil
}
func Connect ( conn net . PacketConn , addr net . Addr ) ( * Peer , error ) { srv := & Peer { Peer : rudp . Connect ( conn , addr ) } ack , err := srv . Send ( rudp . Pkt { Data : [ ] byte { 0 , 0 } } ) if err != nil { return nil , err } select { case <- time . After ( 8 * time . Second ) : srv . SendDisco ( 0 , true ) srv . Close ( ) return nil , ErrServerUnreachable case <- ack : } return srv , nil }
Connect connects to the server on conn
and closes conn when the Peer disconnects
Connect connects to the server on conn and closes conn when the Peer disconnects