英文:
How can I pass a socket between instances on App Engine using the Go runtime?
问题
Python运行时通过pickling the connection来实现。在经典App Engine上,使用Go运行时的google.golang.org/appengine/socket是否有类似的方法来共享套接字?
英文:
The Python runtime allows it by pickling the connection. Is there a similar way to share sockets using the Go runtime on classic App Engine with google.golang.org/appengine/socket?
答案1
得分: 0
描述符在Go API中没有暴露出来:https://github.com/golang/appengine/blob/master/socket/socket_classic.go#L152
type Conn struct {
    ctx    context.Context
    desc   string
    offset int64
    prot          pb.CreateSocketRequest_SocketProtocol
    local, remote *pb.AddressPort
    readDeadline, writeDeadline time.Time // optional
}
desc是在另一端重建套接字所需的内容。
你可以在GitHub上fork这个库,将conn结构体修改为公开所需的desc属性,然后将导入更改为github.com/YOURUSERNAME/appengine/socket而不是appengine/socket。
这是一项很大的工作,所以如果你能想出其他解决方法,可能会更好。尽管如此,这应该是可行的。
英文:
The descriptor isn't exposed in the Go API: https://github.com/golang/appengine/blob/master/socket/socket_classic.go#L152
type Conn struct {
    ctx    context.Context
    desc   string
    offset int64
    prot          pb.CreateSocketRequest_SocketProtocol
    local, remote *pb.AddressPort
    readDeadline, writeDeadline time.Time // optional
}
desc is what you would need on the other side to reconstruct the socket.
It should be possible fork this library on GitHub, change the conn struct to expose the needed desc property, and then change the import to github.com/YOURUSERNAME/appengine/socket instead of appengine/socket.
It's a lot of work so if you can come up with a different way to solve this you're probably better off. Nevertheless it should be possible.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论