fix(c/libuv/demo): Fix echo_server stream convert
This commit is contained in:
@@ -31,7 +31,7 @@ func main() {
|
|||||||
|
|
||||||
// Bind the server to the specified address and port
|
// Bind the server to the specified address and port
|
||||||
(&server).Bind((*net.SockAddr)(c.Pointer(&addr)), 0)
|
(&server).Bind((*net.SockAddr)(c.Pointer(&addr)), 0)
|
||||||
res := (*libuv.Stream)(&server).Listen(DEFAULT_BACKLOG, OnNewConnection)
|
res := (*libuv.Stream)(unsafe.Pointer(&server)).Listen(DEFAULT_BACKLOG, OnNewConnection)
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
c.Fprintf(c.Stderr, c.Str("Listen error: %s\n"), libuv.Strerror((libuv.Errno(res))))
|
c.Fprintf(c.Stderr, c.Str("Listen error: %s\n"), libuv.Strerror((libuv.Errno(res))))
|
||||||
return
|
return
|
||||||
@@ -110,8 +110,8 @@ func OnNewConnection(server *libuv.Stream, status c.Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accept the new connection and start reading data.
|
// Accept the new connection and start reading data.
|
||||||
if server.Accept((*libuv.Stream)(client)) == 0 {
|
if server.Accept((*libuv.Stream)(unsafe.Pointer(client))) == 0 {
|
||||||
(*libuv.Stream)(client).StartRead(AllocBuffer, EchoRead)
|
(*libuv.Stream)(unsafe.Pointer(client)).StartRead(AllocBuffer, EchoRead)
|
||||||
} else {
|
} else {
|
||||||
(*libuv.Handle)(c.Pointer(client)).Close(nil)
|
(*libuv.Handle)(c.Pointer(client)).Close(nil)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user