go-hep.org/x/hep@v0.38.1/xrootd/handshake.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package xrootd // import "go-hep.org/x/hep/xrootd" 6 7 import ( 8 "context" 9 10 "go-hep.org/x/hep/xrootd/internal/xrdenc" 11 "go-hep.org/x/hep/xrootd/xrdproto" 12 "go-hep.org/x/hep/xrootd/xrdproto/handshake" 13 ) 14 15 func (sess *cliSession) handshake(ctx context.Context) error { 16 streamID := xrdproto.StreamID{0, 0} 17 responseChannel, err := sess.mux.ClaimWithID(streamID) 18 if err != nil { 19 return err 20 } 21 22 req := handshake.NewRequest() 23 var wBuffer xrdenc.WBuffer 24 err = req.MarshalXrd(&wBuffer) 25 if err != nil { 26 return err 27 } 28 29 resp, _, err := sess.send(ctx, streamID, responseChannel, wBuffer.Bytes(), nil, 0) 30 // TODO: should we react somehow to redirection? 31 if err != nil { 32 return err 33 } 34 35 var result handshake.Response 36 if err = result.UnmarshalXrd(xrdenc.NewRBuffer(resp)); err != nil { 37 return err 38 } 39 40 sess.protocolVersion = result.ProtocolVersion 41 42 return nil 43 }