Hi,
I have developed a VB.NET windows application to read mails from the server.
I am using tcpclient object to read mail from mail server. I am uisng the IMAP and POP protocols for reading the mails. For this i used to send command using write command of ssl stream and read the response using the reader
Dim sslstream As Net.Security.SslStream
Dim reader As StreamReader = Nothing
Dim objTCP As New TcpClient
objTCP.Connect(POPserver, Port)
sslstream = New Net.Security.SslStream(objTCP.GetStream())
reader = New StreamReader(sslstream)
writing data(commands)
Data = strCmd & vbCrLf
SzData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArr ay())
sslstream.Write(SzData, 0, SzData.Length)
reading the response
tmpString = reader.ReadLine()
If tmpString.Substring(0, 4) <> "-ERR" Then
While (tmpString <> "." )
tmpString = reader.ReadLine
End While
End If
The application has to run 24/7 and 365 days with out any stopping.
Problem i am facing i am getting the exceptions while writing and reading
some times application hangs also
Applications is almost done and in the final stage I am stuck with this issue.
I am pasting the exception i am getting while writing and reading
writing exception
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
reading exception
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host
can anybody please suggest me a solution to fix this
thanks & regards
nevviin
|