PHP Classes

File: examples/server.go

Recommend this page to a friend!
  Classes of Wolfy-J   goridge   examples/server.go   Download  
File: examples/server.go
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: goridge
Run Golang code from PHP calling its RPC server
Author: By
Last change: CS and linters
CS and linters
CS and linters
release 2.0.0
Date: 6 years ago
Size: 548 bytes
 

Contents

Class file image Download
package main import ( "fmt" "github.com/spiral/goridge" "log" "net" "net/rpc" ) // App sample type App struct{} // Hi returns greeting message. func (a *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)) log.Printf("started") for { conn, err := ln.Accept() if err != nil { continue } log.Printf("new connection %+v", conn) go rpc.ServeCodec(goridge.NewCodec(conn)) } }