Re: IOCP and closing sockets
- From: David Barrett-Lennard <davidbl@xxxxxxxxxxxx>
- Date: Sun, 24 Jul 2011 21:54:50 -0700 (PDT)
On Jul 25, 10:58 am, "Chris M. Thomasson" <cris...@xxxxxxxxxxx> wrote:
"David Barrett-Lennard" <davi...@xxxxxxxxxxxx> wrote in message
news:733c4aeb-3fad-4c92-b4e4-111b84642c04@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 24, 2:16 pm, "Chris M. Thomasson" <cris...@xxxxxxxxxxx> wrote:
"David Schwartz" <dav...@xxxxxxxxxxxxx> wrote in message
news:66aa7c5a-16af-41cb-9906-38c90e4ebfd6@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 18, 12:43 am, "Chris M. Thomasson" <cris...@xxxxxxxxxxx> wrote:
Using `closesocket()' and hashed locking scheme.to per-socket stateThe problem is that you cannot open or accept any new sockets during
is
usually just fine. Simply set a flag indicating that `closesocket()'
has
been called. Then let pending I/O drain. When the "cancelled"
completions
come in they will notice that the flag has been set, which should
prevent
them from making any further calls with the socket handle.
this time window. That seems to be an awfully high price to pay.
Yikes. I meant to say `DisconnectEx()' instead of `closesocket()'! Also,
it's dangerous to call `closesocket()' when there is a pending
`AcceptEx()/ConnextEx()' call. IIRC, it might cause a memory leak.
Also, IIRC, `DisconnectEx()' can be safely used to close a socket while
it
has pending I/O operations... According to:
http://www.microsoft.com/mspress/books/sampchap/5726.aspx#SampleChapter
I don't see where it suggests DisconnectEx can be used to abort a
pending AcceptEx/ConnectEx. It appears to me that both the ch6 of
Network Programming you referenced and the MSDN documentation on
DisconnectEx imply the function is (only) intended to be used on a
connected socket.
It basically says that `DisconnectEx()' will return `WSA_IO_PENDING' if the
socket has pending overlapped I/O operations. AFAICT, pending
`AcceptEx()/ConnectEx()' count as pending overlapped I/O ops.
I had thought in that context "pending I/O operations" only referred
to the meaningful pending I/O operations on a connected socket (which
are reads and writes).
The precondition on DisconnectEx that the given socket handle is
already connected is explicit in MSDN:
http://msdn.microsoft.com/en-us/library/ms737757(v=vs.85).aspx
states:
"The DisconnectEx function closes a connection on a socket, and
allows the socket handle to be reused",
and the parameter hSocket is described as:
"A handle to a connected, connection-oriented socket"
.
- Follow-Ups:
- Re: IOCP and closing sockets
- From: David Barrett-Lennard
- Re: IOCP and closing sockets
- References:
- IOCP and closing sockets
- From: David Barrett-Lennard
- Re: IOCP and closing sockets
- From: David Schwartz
- Re: IOCP and closing sockets
- From: Chris M. Thomasson
- Re: IOCP and closing sockets
- From: David Barrett-Lennard
- Re: IOCP and closing sockets
- From: Chris M. Thomasson
- Re: IOCP and closing sockets
- From: David Barrett-Lennard
- Re: IOCP and closing sockets
- From: Chris M. Thomasson
- Re: IOCP and closing sockets
- From: David Schwartz
- Re: IOCP and closing sockets
- From: Chris M. Thomasson
- Re: IOCP and closing sockets
- From: David Barrett-Lennard
- Re: IOCP and closing sockets
- From: Chris M. Thomasson
- IOCP and closing sockets
- Prev by Date: Re: IOCP and closing sockets
- Next by Date: Re: snippet from producer-consumer code
- Previous by thread: Re: IOCP and closing sockets
- Next by thread: Re: IOCP and closing sockets
- Index(es):
Relevant Pages
|