468,513 Members | 1,750 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

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 3278
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by 0to60 | last post: by
1 post views Thread by kmacintyre | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.