G
Guoqi Zheng
Dear sir,
I am using .NET tcpClient to connect to remote POP server. When I get the
string from server response, the string always contains many white space.
I think the ReceiveBufferSize is always too big, it seems to me that server
always response with a fix buffer size, but send the response stream in 3
times. I tried to get rid of those white space by trim or regex, but not any
lucky,
any one understand what I am taking about?
Any help will be appreciated!!! Please see my code example below.
Do While (qqNetworkStream.DataAvailable)
Dim bytes(qqTcpClient.ReceiveBufferSize) As Byte
qqNetworkStream.Read(bytes, 0, CInt(qqTcpClient.ReceiveBufferSize))
Dim tempString As String = System.Text.Encoding.UTF8.GetString(bytes)
Tmr = Now.TimeOfDay.TotalSeconds - Start
Dim boolTest As Boolean = False
boolTest = Regex.IsMatch(fReturn, "\r\n\.\r\n",
RegexOptions.Singleline)
If boolTest = True Or Tmr > m_TimeOut Then
Exit Do
End If
System.Threading.Thread.Sleep(300)
Loop
Return tempString
--
Kind regards
Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com
I am using .NET tcpClient to connect to remote POP server. When I get the
string from server response, the string always contains many white space.
I think the ReceiveBufferSize is always too big, it seems to me that server
always response with a fix buffer size, but send the response stream in 3
times. I tried to get rid of those white space by trim or regex, but not any
lucky,
any one understand what I am taking about?
Any help will be appreciated!!! Please see my code example below.
Do While (qqNetworkStream.DataAvailable)
Dim bytes(qqTcpClient.ReceiveBufferSize) As Byte
qqNetworkStream.Read(bytes, 0, CInt(qqTcpClient.ReceiveBufferSize))
Dim tempString As String = System.Text.Encoding.UTF8.GetString(bytes)
Tmr = Now.TimeOfDay.TotalSeconds - Start
Dim boolTest As Boolean = False
boolTest = Regex.IsMatch(fReturn, "\r\n\.\r\n",
RegexOptions.Singleline)
If boolTest = True Or Tmr > m_TimeOut Then
Exit Do
End If
System.Threading.Thread.Sleep(300)
Loop
Return tempString
--
Kind regards
Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com