Re: closing ASyncSocket
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 08 Mar 2006 15:00:25 -0500
If you want to guarantee that everything is sent, call the ShutDown method (note the
uppercase "D"). Its argument is whatever operations you want to shut down, and although
it doesn't give the name of a type, the documentation says that 0 to shut down receives, 1
to shut down sends, and 2 to shut down both. This guarantees that pending Send operations
will be flushed out. Close is not required to make sure that pending data is sent.
joe
On Wed, 8 Mar 2006 18:52:48 +0800, "Bill Brehm" <<don't want any spam>> wrote:
I had asked part of this in another thread but i have more related questionsJoseph M. Newcomer [MVP]
so I repeat one part.
1. When is it safe after sending to call Close()? I have it implemented now
where I close from within the OnSend() call when I have no further data to
send. I thought that means the data is safely underway. But it seems that
sometimes the data is received on the other side and sometimes it isn't. I'm
not sure if the connection being closed before the other side reads the data
out is the cause of the problem or if I maybe have another problem.
2. Then because of that problem, I decided to try Close()ing on the
receiving side (Server) after I received the last data. This was an
improvement because the data was always received. But it seems the sending
side (Client) doesn't realize the connection is closed. It does get the
OnClose() call. But when I try to initiate another transaction by having the
client connect to the server, it gets an error that it is already connected
(10056). Do I need to call Close() from within the OnClose() call triggered
by the other side?
I'm sure i'll have more later. Thanks...
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: closing ASyncSocket
- From: Bill Brehm
- Re: closing ASyncSocket
- References:
- closing ASyncSocket
- From: Bill Brehm
- closing ASyncSocket
- Prev by Date: Re: New essay: whereis utility
- Next by Date: Re: How to avoid maximizing dialog while double click'ing on titlebar..
- Previous by thread: closing ASyncSocket
- Next by thread: Re: closing ASyncSocket
- Index(es):
Relevant Pages
|