G
Gary Howe
I'm trying to send data from a PDA to a listener using TcpClient and
NetworkStream.
The problem is that is seems to not being recieving all the data. It
looks like there is a up limit of 45000 or so bytes.
Anyone having any ideas on how to send an unlimited or unknown ammount
of data from a PDA to a listener. your help would be greatly
appreciated.
Code information below
----------------------
Using this code to recieve the data.
if(netStream.CanWrite && netStream.CanRead)
{
string myCompleteMessage = "";
byte[] bytes = new byte[1024];
int numberOfBytesRead = 0;
do
{
numberOfBytesRead = netStream.Read(bytes, 0, bytes.Length);
myCompleteMessage = String.Concat(myCompleteMessage,
Encoding.ASCII.GetString(bytes, 0, numberOfBytesRead));
}while(netStream.DataAvailable);
Console.WriteLine(myCompleteMessage);
}
when netStream.DataAvailable becomes false total byte read are 45000
or so. When the code below sent 161,000 byes.
Byte[] byteResponse;
int Starthere = 0;
int ByteChunk = 1024;
while(Starthere < XMLSTR.Length)
{
if((Starthere + ByteChunk) < XMLSTR.Length)
{
byteResponse=
Encoding.ASCII.GetBytes(XMLSTR.ToString(Starthere,ByteChunk).ToCharArray());
client.GetStream().Write(byteResponse,0,byteResponse.Length);
Starthere += ByteChunk;
}
else
{
byteResponse =
Encoding.ASCII.GetBytes(XMLSTR.ToString(Starthere,XMLSTR.Length).ToCharArray());
client.SendBufferSize = byteResponse.Length;
client.GetStream().Write(byteResponse,0,byteResponse.Length);
Starthere = XMLSTR.Length + 10; // make sure starthere is
larger.
}
}
the data string being sent looks like.
<xmlset>
<item>
<name>Aname</name>
<value> a value</value>
</item>
<item>
<name>Aname</name>
<value> a value</value>
</item>
<item>
<name>Aname</name>
<value> a value</value>
</item>
</xmlset>
NetworkStream.
The problem is that is seems to not being recieving all the data. It
looks like there is a up limit of 45000 or so bytes.
Anyone having any ideas on how to send an unlimited or unknown ammount
of data from a PDA to a listener. your help would be greatly
appreciated.
Code information below
----------------------
Using this code to recieve the data.
if(netStream.CanWrite && netStream.CanRead)
{
string myCompleteMessage = "";
byte[] bytes = new byte[1024];
int numberOfBytesRead = 0;
do
{
numberOfBytesRead = netStream.Read(bytes, 0, bytes.Length);
myCompleteMessage = String.Concat(myCompleteMessage,
Encoding.ASCII.GetString(bytes, 0, numberOfBytesRead));
}while(netStream.DataAvailable);
Console.WriteLine(myCompleteMessage);
}
when netStream.DataAvailable becomes false total byte read are 45000
or so. When the code below sent 161,000 byes.
Byte[] byteResponse;
int Starthere = 0;
int ByteChunk = 1024;
while(Starthere < XMLSTR.Length)
{
if((Starthere + ByteChunk) < XMLSTR.Length)
{
byteResponse=
Encoding.ASCII.GetBytes(XMLSTR.ToString(Starthere,ByteChunk).ToCharArray());
client.GetStream().Write(byteResponse,0,byteResponse.Length);
Starthere += ByteChunk;
}
else
{
byteResponse =
Encoding.ASCII.GetBytes(XMLSTR.ToString(Starthere,XMLSTR.Length).ToCharArray());
client.SendBufferSize = byteResponse.Length;
client.GetStream().Write(byteResponse,0,byteResponse.Length);
Starthere = XMLSTR.Length + 10; // make sure starthere is
larger.
}
}
the data string being sent looks like.
<xmlset>
<item>
<name>Aname</name>
<value> a value</value>
</item>
<item>
<name>Aname</name>
<value> a value</value>
</item>
<item>
<name>Aname</name>
<value> a value</value>
</item>
</xmlset>