// ServeCodec is like ServeConn but uses the specified codec to
// decode requests and encode responses.
ServeCodec is like ServeConn but uses the specified codec to
decode requests and encode responses.
// ServeCodec is like ServeConn but uses the specified codec to // decode requests and encode responses .
func (server *Server) ServeCodec(ctx context.Context, codec ServerCodec) {
	sending := new(sync.Mutex)
	arg1 := reflect.ValueOf(ctx)
	for {
		mtype, req, argv, replyv, keepReading, err := server.readRequest(codec)
		if err != nil {
			if debugLog && err != io.EOF {
				log.Println("rpc:", err)
			}
			if !keepReading {
				break
			}
			if req != nil {
				server.sendResponse(sending, req, invalidRequest, codec, err)
				server.freeRequest(req)
			}
			continue
		}
		go server.call(sending, mtype, req, arg1, argv, replyv, codec)
	}
	codec.Close()
}
func ( server * Server ) ServeCodec ( ctx context . Context , codec ServerCodec ) { sending := new ( sync . Mutex ) arg1 := reflect . ValueOf ( ctx ) for { mtype , req , argv , replyv , keepReading , err := server . readRequest ( codec ) if err != nil { if debugLog && err != io . EOF { log . Println ( " " , err ) } if ! keepReading { break } if req != nil { server . sendResponse ( sending , req , invalidRequest , codec , err ) server . freeRequest ( req ) } continue } go server . call ( sending , mtype , req , arg1 , argv , replyv , codec ) } codec . Close ( ) }
ServeCodec is like ServeConn but uses the specified codec to
decode requests and encode responses.
ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses .
// send a response if we actually managed to read a header.