golang 代码: package main import ( "fmt" "net" "net/rpc" "GitHub.com/spiral/Goridge/v2" ) type App struc
golang 代码:
package main
import (
"fmt"
"net"
"net/rpc"
"GitHub.com/spiral/Goridge/v2"
)
type App struct{}
func (*App) Hi(name string, r *string) error {
*r = fmt.Sprintf("hello %s!", name)
return nil
}
type Ceshi struct{}
func (*Ceshi) Demo(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))
rpc.Register(new(Ceshi))
for {
conn, err := ln.Accept()
if err != nil {
continue
}
go rpc.ServeCodec(goridge.NewCodec(conn))
}
}
PHP代码:
use Spiral\Goridge\RPC;
use Spiral\Goridge\Relay;
$rpc = new RPC(Relay::create('tcp://127.0.0.1:6001'));
echo $rpc->call("Ceshi.Demo", "ceshi");
来源地址:https://blog.csdn.net/qq_32421489/article/details/131940916
--结束END--
本文标题: php-golang-rpc spiral/goridge库和php spiral/goridge2.4.5实践
本文链接: https://lsjlt.com/news/391964.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-04-05
2024-04-05
2024-04-05
2024-04-04
2024-04-05
2024-04-05
2024-04-05
2024-04-05
2024-04-04
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0