Currently I have some code which looks like this:
My getResponse code looks like:
Everytime I hit the networkStream.Read line, it stops dead in its track. What could be the problem?
Code:
Public Function connect(ByVal ip As String, ByVal port As Integer, ByVal type As type)
client.Connect(ip, port)
networkStream = New SslStream(client.GetStream, False, New RemoteCertificateValidationCallback(AddressOf TrustAllCertificatesCallback))
If type = SMTP.type.TLS Then
Dim clearTextReader = New StreamReader(client.GetStream())
Dim clearTextWriter = New StreamWriter(client.GetStream()) With {.AutoFlush = True}
Debug.WriteLine(clearTextReader.ReadLine())
clearTextWriter.WriteLine("HELO")
Debug.WriteLine(clearTextReader.ReadLine())
clearTextWriter.WriteLine("STARTTLS")
Debug.WriteLine(clearTextReader.ReadLine())
networkStream.AuthenticateAsClient(ip)
SendText("HELO")
getResponse()
Else
networkStream.AuthenticateAsClient(ip)
getResponse()
SendText("HELO")
getResponse()
End If
Return Nothing
End FunctionCode:
Dim bytes() As Byte
ReDim bytes(client.ReceiveBufferSize)
networkStream.Read(bytes, 0, CInt(client.ReceiveBufferSize))
Debug.WriteLine(Encoding.ASCII.GetString(bytes))