Re[2]: Windows, асинхронный режим ASIO
От: Michaels1  
Дата: 20.01.11 01:55
Оценка:
Здравствуйте, savitar, Вы писали:

S>колбэк с ошибкой вызвается для закрытого сокета, а не для вновь созданного. это легко проверить не создавая нового сокета и не вызывая async_connect.


Но почему вызывается connect_handler()? В документации сказано,

cancel() causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the asio::error::operation_aborted error.


connect_handler() при первом коннекте солбщил 0 (нет ошибки) — то есть операция async_connect() завершась для этого сокета, она уже не должна вызываться с asio::error::connection_abort при разрушении сокета повторно. Разве нет?

Еще в документации нашел момент годе говорится

Remarks

Calls to cancel() will always fail with asio::error::operation_not_supported when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless ASIO_ENABLE_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:

It will only cancel asynchronous operations that were initiated in the current thread.
It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.
For portable cancellation, consider using one of the following alternatives:

Disable asio's I/O completion port backend by defining ASIO_DISABLE_IOCP.
Use the close() function to simultaneously cancel the outstanding operations and close the socket.
When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.


У меня как раз WinXP, приложение состоит из одного потока, никаких дополнительных дефайнов (навроде ASIO_DISABLE_IOCP) я не указывал.
Или я что-то не так понял?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.