456
Chương 11: Lập trình mạng
w.Write(ClientMessages.Disconnect);
} else {
Console.WriteLine("Connection not completed.");
}
// Đóng connection socket.
client.Close();
Console.WriteLine("Port closed.");
} catch (Exception err) {
Console.WriteLine(err.ToString());
}
Console.ReadLine();
}
}
Dưới đây là transcript phía server:
About to initialize port.
Listening for a connection...
Connection accepted.
Connection completed.
Disconnect request received.
Connection closed.
Listener stopped.
Và dưới đây là transcript phía client:
Attempting to connect to the server on port 8000.
Connection established.
Connected.
Press Enter to disconnect.
Disconnecting...
Port closed.