golang代码: go get github.com/roadrunner-server/goridge/v3
package main
import (
"fmt"
"net"
"net/rpc"
goridgeRpc "github.com/roadrunner-server/goridge/v3/pkg/rpc"
)
type App struct{}
func (s *App) Hi(name string, r *string) error {
*r = fmt.Sprintf("Hello, %s!", name)
return nil
}
func main() {
ln, err := net.Listen("tcp", ":6001")
if err != nil {
panic(err)
}
_ = rpc.Register(new(App))
for {
conn, err := ln.Accept()
if err != nil {
continue
}
_ = conn
go rpc.ServeCodec(goridgeRpc.NewCodec(conn))
}
}
//***********************************************/
php代码:
use Spiral\Goridge\RPC\RPC;
use Spiral\Goridge\Relay;文章来源:https://www.toymoban.com/news/detail-611999.html
$rpc = new RPC(Relay::create('tcp://127.0.0.1:6001'));
echo $rpc->call("App.Hi", "ceshi");文章来源地址https://www.toymoban.com/news/detail-611999.html
到了这里,关于php-golang-rpc使用roadrunner-server/goridge/v3/pkg/rpc和php的spiral/goridge3.2实践的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!