By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

Q: Socket class - disconnect notify??

P: n/a
Is there a way to be notifyed (callback, event,...) when the connection of
socket was closed... The WinSock activex in vb6 had event ondisconnect...

I get exception when i try to send some data, but i need disconnect info
sooner.

I have a solution with timer that checks the state of socket, but i don't
like to use timers...

best re,
habix
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you have a pending read waiting on the Socket, it will fail with an
exception when the socket is closed. That should give you more timely
notification about the disconnection.
"HABJAN 展ga" <habix[AT]intelcom[DOT]si> wrote in message
news:bn********@enews3.newsguy.com...
Is there a way to be notifyed (callback, event,...) when the connection of
socket was closed... The WinSock activex in vb6 had event ondisconnect...

I get exception when i try to send some data, but i need disconnect info
sooner.

I have a solution with timer that checks the state of socket, but i don't
like to use timers...

best re,
habix

Nov 20 '05 #2

P: n/a
Thanks for response Will,

I found a sample class, that uses frameworks socket class and exports itself
with events and methods like WinSock.ocx in VB6. I looked up how the
disconnect event was raised:

The class uses async callbacks for reading the data, and when you call
EndReceive function on callback, the return value is BytesRead. If you get 0
bytes, the disconnect event is raised.

best re,
habix

"William Armstrong" <wi********@SPAMcrowsnest-design.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
If you have a pending read waiting on the Socket, it will fail with an
exception when the socket is closed. That should give you more timely
notification about the disconnection.
"HABJAN 展ga" <habix[AT]intelcom[DOT]si> wrote in message
news:bn********@enews3.newsguy.com...
Is there a way to be notifyed (callback, event,...) when the connection of socket was closed... The WinSock activex in vb6 had event ondisconnect...
I get exception when i try to send some data, but i need disconnect info
sooner.

I have a solution with timer that checks the state of socket, but i don't like to use timers...

best re,
habix


Nov 20 '05 #3

P: n/a
On Thu, 23 Oct 2003 12:14:39 +0200, "HABJAN 展ga"
<habix[AT]intelcom[DOT]si> wrote:
Is there a way to be notifyed (callback, event,...) when the connection of
socket was closed... The WinSock activex in vb6 had event ondisconnect...

I get exception when i try to send some data, but i need disconnect info
sooner.

I have a solution with timer that checks the state of socket, but i don't
like to use timers...

best re,
habix


You should catch and handle the exception (fire your own event if you
need to). You will also note that a socket can be closed _during_ a
send or read operation. In fact, you should handle all exceptions.

Rgds,

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.