func (client *Client) newFcall() *g9p.Fcall { select { case tc := <-client.tchan: return tc default: } return g9p.NewFcall(client.msize) }
// NewClient creates a client object for the 9p server connected // to by c. It negotiates the dialect and msize for the // connection. Returns a Client object, or Error. func NewClient(c io.ReadWriteCloser, msize uint32, dotu bool, log g9p.Logger) (*Client, error) { client := new(Client) client.conn = c client.msize = msize client.dotu = dotu client.tagpool = newPool(uint32(g9p.NOTAG)) client.fidpool = newPool(g9p.NOFID) client.reqout = make(chan *req) client.finished = make(chan error, 1) client.reqchan = make(chan *req, 16) client.tchan = make(chan *g9p.Fcall, 16) client.log = log ver := "9P2000" if client.dotu { ver = "9P2000.u" } go client.recv() go client.send() tc := g9p.NewFcall(client.msize) err := g9p.PackTversion(tc, client.msize, ver) if err != nil { goto error } rc, err := client.rpc(tc) if err != nil { goto error } if rc.Msize < client.msize { client.msize = rc.Msize } client.dotu = rc.Version == "9P2000.u" && client.dotu return client, nil error: if log != nil { log.Log9p(nil) } return nil, err }