|
-
Mar 28th, 2003, 02:27 PM
#1
Thread Starter
Addicted Member
Sockets Get Stream .net
I have an appliction which is receiving inbound xml which it processes and writes to a database.
I am having a problem when receiving a large stream. In winsock api I would wait until the whole message was received and parse the streams together to form the file. When I try that here, I do not get the whole file.
Here is an example of the code.
VB Code:
Do
Dim InBuff(200000) As Byte
Client.GetStream().Read(InBuff, 0, InBuff.Length)
txtLog.Text = txtLog.Text & vbCrLf & "[" & Now & "] >Processing incoming request."
Application.DoEvents()
temp = temp & System.Text.Encoding.Default.GetString(InBuff)
temp = Trim(temp)
Loop Until Client.GetStream.DataAvailable = False
Sometimes I get the whole file on the first run. Could I get some he
-
Mar 28th, 2003, 05:58 PM
#2
PowerPoster
This should work. If you need me to convert it to VB.NET, let me know...
Code:
MemoryStream m = new MemoryStream();
int iRead;
byte[] bytes = new byte[4096];
while((iRead = ns.Read(bytes, 0, bytes.Length)) > 0)
{
m.Write(bytes, 0, iRead);
}
string output = System.Text.ASCIIEncoding.ASCII.GetString(m.ToArray());
-
Mar 31st, 2003, 08:25 AM
#3
Thread Starter
Addicted Member
Reply
Actually, I am using the TcpClient. If I say m.write it will attempt to write it back to the TCPServer I have written or am I wrong on this?
-
Mar 31st, 2003, 11:49 AM
#4
PowerPoster
MemoryStream just acts as a temporty backing store (memory) for data. The code I posted can be substitued with your do loop..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|