I am sending messages to kiwi syslog server from c# .net client application using TCP.
The issue scenario is as given below.
1. Connect to kiwi syslog server from client app.
2. Close kiwi syslog server.
3. Now send 2 messages from client app to kiwi server.
4. First message is sent successfully without any exception
5. Second message is not sent and it throws an exception " Unable to write data to the transport connection: An established connection was aborted by the software in your host machine." (which is the desired behavior).
I expect the exception for the first message also since I closed the kiwi syslog server before sending both messages.
Is there a way to detect the connection loss immediately in client side when kiwi server is closed?
Code snippet
//Connection to kiwi server is established using this method
public void Connect()
{
var tcpClient = new TcpClient(hostname, port);
tcpClientStream = tcpClient.GetStream();
}.
//Message is send using the below method.
public void Send(SyslogMessage message, IMessageSerializer serializer)
{
tcpClientStream.Write(datagramBytes, 0, datagramBytes.Length);
tcpClientStream.Flush();
}