System.Net.Sockets class

A

Alain Dekker

Hi,

I've created a socket like this:

ipAddress = ipAddress.Parse(strAddress)
ipRemoteEP = New IPEndPoint(ipAddress, nPort)

m_Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
m_Socket.BeginConnect(ipRemoteEP, AddressOf ConnectCallback, m_Socket)

and that all works fine (ie. the ConnectCallBack function is called when the
connection is made). However, I've hit a snag: How do I get signalled when
the remote server disconnects (crashes/shuts down/closes the
connection/etc)?

Thanks,
Alain
 
T

Tom Shelton

Hi,

I've created a socket like this:

ipAddress = ipAddress.Parse(strAddress)
ipRemoteEP = New IPEndPoint(ipAddress, nPort)

m_Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp)
m_Socket.BeginConnect(ipRemoteEP, AddressOf ConnectCallback, m_Socket)

and that all works fine (ie. the ConnectCallBack function is called when the
connection is made). However, I've hit a snag: How do I get signalled when
the remote server disconnects (crashes/shuts down/closes the
connection/etc)?

You don't... That's because that's how tcp/ip is implemented. You know when
the remote host is down when you do a receive on the socket and it returns 0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top