473,327 Members | 1,952 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,327 software developers and data experts.

networkstream.read

I'm working on a program that talks to the Yahoo chat servers. But I have
run into a small problem and I'm not sure what to do next. After I
successfully log into yahoo and receive my cookies I think login to their
chat servers. It's at this point I am having the problem. When the following
code executes:

networkstream.Read(bytes, 0, CInt(tcpClient2.ReceiveBufferSize))

Dim returndata As String = Encoding.ASCII.GetString(bytes)

txtReturndata.Text = txtReturndata.Text & returndata
returndata = "YCHT

There is no closing quote either which I find odd since return data is
clearly a string. I believe that there is some character or something being
received after YCHT that is causing the Encoding.ASCII.GetString to choke.
Any suggestions for a method that might work better? Thanks in advance.

Nov 20 '05 #1
1 3490
I think the problem is that the buffer is too small, either on your side or
on the sender's side. You need to increase the buffer and read from the
stream until the stream is empty. The stream probably still contains more
response from the sender. Set it on a loop:

Do
BytesRead = stream.Read(data, 0, data.Length)
TotalBytes += BytesRead
TotalData = [String].Concat(TotalData,
System.Text.Encoding.ASCII.GetString(data, 0, BytesRead))
Loop While stream.DataAvailable

Good luck.

"Steve" <me**********@stephendcarlton.com.wine> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
I'm working on a program that talks to the Yahoo chat servers. But I have
run into a small problem and I'm not sure what to do next. After I
successfully log into yahoo and receive my cookies I think login to their
chat servers. It's at this point I am having the problem. When the following code executes:

networkstream.Read(bytes, 0, CInt(tcpClient2.ReceiveBufferSize))

Dim returndata As String = Encoding.ASCII.GetString(bytes)

txtReturndata.Text = txtReturndata.Text & returndata
returndata = "YCHT

There is no closing quote either which I find odd since return data is
clearly a string. I believe that there is some character or something being received after YCHT that is causing the Encoding.ASCII.GetString to choke.
Any suggestions for a method that might work better? Thanks in advance.


Nov 20 '05 #2

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

Similar topics

1
by: cmjman | last post by:
I have an issue where networkStream.Write doesn't perform its write downstream from my client program until the network stream is closed. I then see the data that was sent appear on the other side....
4
by: 0to60 | last post by:
I have a class that wraps a TcpClient object and manages all the async reading of the socket. It works really nice, and I use it all over the place. But there's this ONE INSTANCE where I create...
1
by: Casey Watson | last post by:
Hi :) I'm having some major trouble with an XML Client/Server application that I am writing. I am using NetworkStream with CryptoStream to Read and Write XML between computers. Now, whenever I...
1
by: kmacintyre | last post by:
I am trying to us a simple NetworkStream to transfer a file over tcp. This works most of the time, but one specific file never downloads(.mdb file). It seems to close the socket and I get an...
6
by: Ryan | last post by:
Hi, I am confused with how NetworkStream works. My application needs to handle heavy requests sent through TCP socket connection. I use NetworkStream.Read method to get the stream...
0
by: Al Wilkerson | last post by:
Hey, Has anyone ever got a "Unable to read data from transport connected" message after reading data from a streamreader composed of a networkstream. For example: Server TcpListener...
4
by: DaveR | last post by:
I have a background thread to accept and process TCP/IP connections. When the application shuts down I want to gracefully terminate it. The thread will block in NetworkStream.Read() waiting for...
5
by: | last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and...
3
by: shahla.saeed | last post by:
hi, plzz check my code and let me know where the problem is lying...becuase whenever i try to tansfer the file of 573KB(mp3) it just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time...
7
by: littleIO | last post by:
Hi, I'm stuck on a very simple problem and just cant seem to get around it, little help would be much appreciated. I have a server which listens, receives calls, processes them and sends back the...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.