Original Post
Hi! Im having a problem sending data from a pocket-pc with windows CE. I can only send about 30-40 bytes and then bytes disapears. The server recievs strings of the wrong length. :( Can someone help me? This is the client code: this is the server:
TcpClient client = new TcpClient(ip, port);
NetworkStream ns = client.GetStream();
StreamWriter sw = new StreamWriter(ns);
StreamReader sr = new StreamReader(ns);
int len = Int32.Parse(textBox1.Text);
sw.WriteLine(len); // write the number of chars in the string to recieve.
sw.WriteLine(getData(len)); // get a random string of length len and send it.
sw.Flush();
ns.Close();
client.Close();
// s is a tcpclient from an acceptance
NetworkStream ns = s.GetStream();
StreamReader sr = new StreamReader(ns);
StreamWriter sw = new StreamWriter(ns);
int bytes = Int32.Parse(sr.ReadLine());
string allData = sr.ReadLine();
if (allData.Length == bytes)
{
Console.WriteLine("OK - Received " + allData.Length + " bytes");
} else {
Console.WriteLine("ERROR - Received " + allData.Length + " bytes");
}
sw.Flush();
ns.close();
client.close();