On Sep 28, 2010, at 15:33 , Patrick wrote:
This is all fine and dandy except when I want to shutdown the server
or connection (not client initiated). The ReadTag (as well as the
other Read functions) blocks until data is received but I want it to
timeout after a specified amount of time. So in essence a polling read
instead of a blocking one. This will allow me to check that the
connection is still valid and either re-enter my message parsing
function or cleanup and exit.
One quick hack that might work: if you have threads anyway, if you
close the file descriptor in the other thread, the read will fail.
This causes input.ReadTag() to return 0.
The more complex hack is to supply your own ZeroCopyInputStream
implementation, and in your implementation of ::Next, implement your
own time out logic.
In my implementation, I manage this by manually managing my own
buffer, so I never call the CodedInputStream routines unless I know
there is sufficient data. This may not be ideal for your application,
so your milage may vary.
You received this message because you are subscribed to the Google Groups "Protocol
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at