G
Guest
I am writing a TCP/IP service.
Server side connections are accepted asynchronously:
//code from AsyncCallback passed to beginAccept
Socket ClientSocket = _AcceptorSocket.EndAccept(ar);
//I then wrap the socket in a network stream:
Stream s = new NetworkStream(ClientSocket);
//I then issue async reads to the stream
s.BeginRead(InBuffer, ByteOffset, Length, new AsyncCallback(OnReadComplete),
InBuffer);
When I come to stop the service, I close the listening socket and itterate
through my collection of NetworkStreams calling
s.Close();
s.Dispose();
Unfortunately the underlying sockets are not actually being closed (i.e. the
clients are not disconnected and netstat reports that the underlying TCP
connections still exist.).
Any ideas?
Dave
Server side connections are accepted asynchronously:
//code from AsyncCallback passed to beginAccept
Socket ClientSocket = _AcceptorSocket.EndAccept(ar);
//I then wrap the socket in a network stream:
Stream s = new NetworkStream(ClientSocket);
//I then issue async reads to the stream
s.BeginRead(InBuffer, ByteOffset, Length, new AsyncCallback(OnReadComplete),
InBuffer);
When I come to stop the service, I close the listening socket and itterate
through my collection of NetworkStreams calling
s.Close();
s.Dispose();
Unfortunately the underlying sockets are not actually being closed (i.e. the
clients are not disconnected and netstat reports that the underlying TCP
connections still exist.).
Any ideas?
Dave