----- Original Message -----
Sent: Friday, May 06, 2005 3:48 AM
Subject: Re: [msvc] closing a client
connection..
We're talking apples and oranges.
A socket is not physical, so you can't
physically close it. To get off on a wild tangent, what is a
socket? We are given a socket handle, but that's not the "socket".
The structure the handle refers to isn't the actual socket itself
either. The data that is transferred on the "socket" isn't the socket
either. You see, it's super abstract. It's not even something that
you can pinpoint in an abstract way. Compare this with a file.
There is a file handle, a structure associated with the handle, etc...
But there is a "file" - it is comprised of the data on the disk. I
can send you a file, I would send the name and the data. I can't send
you a socket, there's nothing to send. When I create a file I have
something, albeit a little abstracted. When I create a socket I have
nothing at all, just a handle that points to a structure, neither of which is
the socket itself. Even in the winsock and lsp code my socket is
abstract, with a file there is a point where abstraction meets reality, with a
socket there is no such meeting place.
So how do you "physically" close a
socket?
Now back to reality...
I think what you meant was when you force a
close outside of your normal IOCP handling code, your closesocket gets called
twice.
So you wrap your socket in a class. The
class notes when the socket is open or when it has been closed. If you
closed it already, don't close it again. The IOCP is just going to
"cancel" all outstanding IOs on that socket when you close it
anyway.
Also lets think about how the socket connection
goes. Usually you have your own "handshake" that is done so that you
know to close the socket gracefully. Your IOCP server receives this "I'm
closing" handshake from the client, and it receives it in the IOCP code.
That's when it closes the socket there. If it doesn't receive the
handshake-close, it doesn't close the socket. And after every read
completion you should be posting another read to replace the one you are
handling that is coming off the stack, unless the socket is closed or in a
closing state.
----- Original Message -----
Sent: Thursday, May 05, 2005 4:27
PM
Subject: Re: [msvc] closing a client
connection..
If I wish to close the socket I first do a
shutdown(..), then closesocket(..). At this point the IOCP
servie thread gets called.
Neil
----- Original Message -----
Sent: Thursday, May 05, 2005 10:23
PM
Subject: Re: [msvc] closing a client
connection..
How do you "physically" close a
socket?
----- Original Message -----
Sent: Thursday, May 05, 2005 4:34
AM
Subject: [msvc] closing a client
connection..
Hi,
I have a IOCP winsock application.
Within the IOCP service routine, I have a closesocket command. But if I
physically close the socket outwith this thread, then the
closesocket(..) gets called withing the thread too. Is there a clean way
of doing this?
Neil
_______________________________________________
msvc mailing
list
msvc@beginthread.com
See
http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.
_______________________________________________
msvc mailing
list
msvc@beginthread.com
See
http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.
_______________________________________________
msvc mailing
list
msvc@beginthread.com
See
http://beginthread.com/mailman/listinfo/msvc_beginthread.com for
subscription changes, and list archive.
_______________________________________________
msvc mailing
list
msvc@beginthread.com
See
http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription
changes, and list archive.