Hello
I wrote a code to d.l message from newgroups and display it in text box, the
code work fine but when the message is large it only display 27k from the
message. any idea how to fix it?
Code:
Imports System.Xml
Imports System.Net.Sock ets
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
Dim _username As String = "********"
Dim _password As String = "********"
Dim tcpClient As New TcpClient
Dim sendBytes As [Byte]()
Dim _buffer As String
tcpClient.Conne ct("news.gigane ws.com", 119)
Dim networkStream As NetworkStream = tcpClient.GetSt ream()
'Read the Welcome message into a byte buffer.
Dim bytes(tcpClient .ReceiveBufferS ize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
'send username to the server
sendBytes = Encoding.ASCII. GetBytes("AUTHI NFO USER " & _username & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
' Send Passwrod to the server
sendBytes = Encoding.ASCII. GetBytes("AUTHI NFO PASS " & _password & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
'reset the buffer
_buffer = ""
'send command to get the message body
sendBytes = Encoding.ASCII. GetBytes("BODY
<4637803c$0$325 75$6c4159fb@tel e2news.tweaknew s.nl>" & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
' Read the NetworkStream into a byte buffer.
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
_buffer = _buffer & Encoding.GetEnc oding("windows-1255").GetStrin g(bytes)
While networkStream.D ataAvailable = True
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
_buffer = _buffer & Encoding.GetEnc oding("windows-1255").GetStrin g(bytes)
End While
TextBox1.Text = _buffer
End Sub
End Class
I wrote a code to d.l message from newgroups and display it in text box, the
code work fine but when the message is large it only display 27k from the
message. any idea how to fix it?
Code:
Imports System.Xml
Imports System.Net.Sock ets
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
Dim _username As String = "********"
Dim _password As String = "********"
Dim tcpClient As New TcpClient
Dim sendBytes As [Byte]()
Dim _buffer As String
tcpClient.Conne ct("news.gigane ws.com", 119)
Dim networkStream As NetworkStream = tcpClient.GetSt ream()
'Read the Welcome message into a byte buffer.
Dim bytes(tcpClient .ReceiveBufferS ize) As Byte
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
'send username to the server
sendBytes = Encoding.ASCII. GetBytes("AUTHI NFO USER " & _username & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
' Send Passwrod to the server
sendBytes = Encoding.ASCII. GetBytes("AUTHI NFO PASS " & _password & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
'reset the buffer
_buffer = ""
'send command to get the message body
sendBytes = Encoding.ASCII. GetBytes("BODY
<4637803c$0$325 75$6c4159fb@tel e2news.tweaknew s.nl>" & vbCrLf)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
' Read the NetworkStream into a byte buffer.
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
_buffer = _buffer & Encoding.GetEnc oding("windows-1255").GetStrin g(bytes)
While networkStream.D ataAvailable = True
ReDim bytes(tcpClient .ReceiveBufferS ize)
networkStream.R ead(bytes, 0, CInt(tcpClient. ReceiveBufferSi ze))
_buffer = _buffer & Encoding.GetEnc oding("windows-1255").GetStrin g(bytes)
End While
TextBox1.Text = _buffer
End Sub
End Class