473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Retrive data in Sockets with VB.NET

BiT
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.Sockets
Imports System.Text
Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
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.Connect("news.giganews.com", 119)

Dim networkStream As NetworkStream = tcpClient.GetStream()

'Read the Welcome message into a byte buffer.

Dim bytes(tcpClient.ReceiveBufferSize) As Byte

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

'send username to the server

sendBytes = Encoding.ASCII.GetBytes("AUTHINFO USER " & _username & vbCrLf)

networkStream.Write(sendBytes, 0, sendBytes.Length)

ReDim bytes(tcpClient.ReceiveBufferSize)

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

' Send Passwrod to the server

sendBytes = Encoding.ASCII.GetBytes("AUTHINFO PASS " & _password & vbCrLf)

networkStream.Write(sendBytes, 0, sendBytes.Length)

ReDim bytes(tcpClient.ReceiveBufferSize)

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

'reset the buffer

_buffer = ""

'send command to get the message body

sendBytes = Encoding.ASCII.GetBytes("BODY
<46***********************@tele2news.tweaknews.nl> " & vbCrLf)

networkStream.Write(sendBytes, 0, sendBytes.Length)

' Read the NetworkStream into a byte buffer.

ReDim bytes(tcpClient.ReceiveBufferSize)

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

_buffer = _buffer & Encoding.GetEncoding("windows-1255").GetString(bytes)

While networkStream.DataAvailable = True

ReDim bytes(tcpClient.ReceiveBufferSize)

networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))

_buffer = _buffer & Encoding.GetEncoding("windows-1255").GetString(bytes)

End While

TextBox1.Text = _buffer

End Sub

End Class

Jun 8 '07 #1
0 2837

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: eric | last post by:
Hi Does any one know how to retrive data from foxpro 2.6 memo field in c#. I just manage to retrive the first row. /Eric
2
by: Terry | last post by:
Any .dll or COM+ for .Net can help me retrive data from a Access file? The table contain several columns and the last one is a container which I store Article; because each article is a little bit...
4
by: Toto | last post by:
Can I retrive a session object by a session ID which is stored in a cookie in my server side code?
2
by: Gian Paolo | last post by:
Hi all on .net 2.0 i have a dataset and a table with some rows. Is there a way to retrive the current row index ? So i can retrive other value of that column... something like...
5
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable...
3
by: =?Utf-8?B?UGV0ZXIgSiwgU2Nhbmlh?= | last post by:
Hello I'm looking for an solution about how to retrive data from an client side located Excel document by using an ASP.Net application. I don't want to upload the file to the server. I just want...
23
nehashri
by: nehashri | last post by:
hi i am designing a database using Ms Access and ASP. i have 3 tables in access namely 'PERSONAL', other as 'POLICY' and 3rd one is named as 'STAFF'. in the contact table i have ID, Name, Children...
1
by: amritranjan | last post by:
How to retrive image file from MS access database and display this in another JSPpage -------------------------------------------------------------------------------- This is my Jsp code for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.