Robert_Zenz
Well-known member
Hello everyone again.
I was writing my own POP3 client but ran into some problems along the way. I could hunt down one of them by now, which seems to be the key to most of the problems I experienced.
I'm using a TCPClient to connect to the server and a NetworkStream to read and write data. This is working great, except one thing: The LIST command delivers me the size of the mail in bytes...but with Lf counted, though, if I start to download the mail with the RETR command, I receive CrLf?!
I'm using the simple NetworkStream.Read(bytes(), offset, length) Method to read from the network. This method already delivers CrLf...but the server counts Lf and so the size I received is totally messed up.
Of course, I'd count the Lf along the way and add them to toReceive (which I do right now, working), but that can't be the solution.
Anybody has ever seen something like this?
Thanks in advance,
Bobby
I was writing my own POP3 client but ran into some problems along the way. I could hunt down one of them by now, which seems to be the key to most of the problems I experienced.
I'm using a TCPClient to connect to the server and a NetworkStream to read and write data. This is working great, except one thing: The LIST command delivers me the size of the mail in bytes...but with Lf counted, though, if I start to download the mail with the RETR command, I receive CrLf?!
I'm using the simple NetworkStream.Read(bytes(), offset, length) Method to read from the network. This method already delivers CrLf...but the server counts Lf and so the size I received is totally messed up.
VB.NET:
'toReceive is an Int32 from the LIST command
'Me.prv_client is the TCPClient
'Me.prv_strm is the NetworkStream from the client
Dim buffer(Me.prv_client.ReceiveBufferSize - 1) As Byte
Dim readAll As Integer = 0
Dim read As Integer = Int32.MaxValue
Do
Array.Clear(buffer, 0, buffer.Length)
read = 0
Try
read = Me.prv_strm.Read(buffer, 0, buffer.Length)
Catch ex As IOException
Me.writeError(ex.Message)
End Try
readAll += read
res.Append(Me.prv_encoding.GetString(buffer, 0, read))
Loop While readAll < toReceive
Of course, I'd count the Lf along the way and add them to toReceive (which I do right now, working), but that can't be the solution.
Anybody has ever seen something like this?
Thanks in advance,
Bobby