Closed dbskccc closed 5 years ago
@tidwall I have a similar question as well,Wake
could do this before, but it was removed in dd88755b17743a570aa642f0b55f5ff71f83853f, is there any replacement for Wake
?
@tidwall I have a similar question as well
There is no way to write directly to a connection. All reads and writes flow through the events. In the previous version of evio it was possible to wake up a connection, which causes an empty Data
event to fire, allowing for an opportunity to send bytes to a specific connection. This operation was removed in 2.0 because I ran into inefficiencies with tracking the paths needed to interrupt a specific loop that was running along side other loops in other goroutines.
I hope to have the wake operation return in the future, once I figure out a fast and safe way to do so.
Thank you for reply. Why cant i send msg to connection directly through fd or net.conn?
I'm assuming that the reason for sending directly to an evio connection is to do so from a separate goroutine. If so, then writing would require synchronizing the file descriptor with the event loop on a different thread. This would slow stuff down. I'm still investigating ways to do this efficiently, or rather without any noticeable penalty to throughput.
I just pushed an update that adds a new Wake
function to evio.Conn
.
Calling conn.Wake()
will trigger an event.Data
for the target connection and pass a nil
for the in
packet. This allows for writing back to a client connection without leaving the loop. The Wake
function can safely be called at any time, from any goroutine, but the Data
event will only fire when the connection is still opened.
there is no Write in Conn, how to send some data to it?