I have a server that listens for a socket connection:
public class Server { private Socket _serverSocket; public Server() { _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _serverSocket.Bind(new IPEndPoint(IPAddress.Any, 1234)); _serverSocket.Listen(1); } public void Start() { _serverSocket.BeginAccept(HandleAsyncConnectionMethod, null); } public void Stop() {
What is the correct (clean) way to close a socket?
Is it enough to call:
_serverSocket.Disconnect(true);
in the Stop () method? or is there any other work that needs to happen to close the connection cleanly?
c # sockets
Anton Jan 16 '09 at 22:47 2009-01-16 22:47
source share