Вопрос

Is there a proper way in Poco to abort a blocking I/O operation from another thread?

Это было полезно?

Решение

Since the thread doing the I/O would be blocked, I don't see any direct way of going in there an cancelling it, besides being nasty and killing the thread explicitly. This is however not advised

Другие советы

Yes, you can call Socket::shutdown(). What happens after that depends on your platform, when recv() returns Poco will throw appropriate exception.

But you do not have to do blocking I/O to start with, since there is Poco::Net::Socket::setBlocking(bool) to enable or disable blocking behavior. Or, even if you want to do blocking, you can still define timeout using Poco::Net::Socket::setSendTimeout() or Poco::NetSocket::setReceiveTimeout()

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top