By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

tcp client and sslstream in .net

P: 1
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
Dec 1 '09 #1
Share this Question
Share on Google+
1 Reply


P: 5
If you use .NET, I highly recommend this IMAP component. I found it after I had spent the whole day to try almost available components on the internet. It's better than the others. Other mail components can be found here: POP3 Component, SMTP Component. If you need mail merge (my project needs it), check out this Mail Merge component.
Mar 16 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.