IOException 10054.
-
Hello all, I am currently developing a application on windows mobile that can receive video image from webcam via a desktop. Here is my code: namespace ABC { public partial class Form1 : Form { // private System.Net.IPHostEntry ips = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); //---port nos and server IP address--- const Int32 PORTNO = 500; string server_IP = "10.0.1.200"; //---size of the video image--- const int SIZEOFIMAGE = 341504; //---use for connecting to the server--- TcpClient client; //--used for sending and receiving data--- byte[] data; //---used for receiving images from the server--- System.Threading.Thread t; private void ReceiveImageLoop() { //---keep on receiving image until an error occurs--- while (ReceiveImage()) { MessageBox.Show("in receive image"); } //---display error message--- MessageBox.Show("Server has stopped responding. Please try restarting the video."); } //---Sends a message to the server--- private void SendMessage(string message) { //---adds a carriage return char--- message += "\n"; try { //---send the text System.Net.Sockets.NetworkStream ns = null; lock (client.GetStream()) { ns = client.GetStream(); byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message); //---sends the text--- ns.Write(bytesToSend, 0, bytesToSend.Length); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //---receive video image from server--- public bool ReceiveImage() { MemoryStream s = new MemoryStream(); NetworkStream nws = client.GetStream(); int counter = 0; int totalBytes = 0; do { MessageBox.Show("trying to read data..."); //---read the incoming data--- int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize); totalBytes += bytesRead; //---write the byte() array in
-
Hello all, I am currently developing a application on windows mobile that can receive video image from webcam via a desktop. Here is my code: namespace ABC { public partial class Form1 : Form { // private System.Net.IPHostEntry ips = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); //---port nos and server IP address--- const Int32 PORTNO = 500; string server_IP = "10.0.1.200"; //---size of the video image--- const int SIZEOFIMAGE = 341504; //---use for connecting to the server--- TcpClient client; //--used for sending and receiving data--- byte[] data; //---used for receiving images from the server--- System.Threading.Thread t; private void ReceiveImageLoop() { //---keep on receiving image until an error occurs--- while (ReceiveImage()) { MessageBox.Show("in receive image"); } //---display error message--- MessageBox.Show("Server has stopped responding. Please try restarting the video."); } //---Sends a message to the server--- private void SendMessage(string message) { //---adds a carriage return char--- message += "\n"; try { //---send the text System.Net.Sockets.NetworkStream ns = null; lock (client.GetStream()) { ns = client.GetStream(); byte[] bytesToSend = System.Text.Encoding.ASCII.GetBytes(message); //---sends the text--- ns.Write(bytesToSend, 0, bytesToSend.Length); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } //---receive video image from server--- public bool ReceiveImage() { MemoryStream s = new MemoryStream(); NetworkStream nws = client.GetStream(); int counter = 0; int totalBytes = 0; do { MessageBox.Show("trying to read data..."); //---read the incoming data--- int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize); totalBytes += bytesRead; //---write the byte() array in
add
data = new byte[client.ReceiveBufferSize];
before bold line hope it helps
dhaim programming is a hobby that make some money as side effect :)
-
add
data = new byte[client.ReceiveBufferSize];
before bold line hope it helps
dhaim programming is a hobby that make some money as side effect :)
-
Hi Mbah, I am still getting an error after inserting your line. Any more suggestions ? Thanks !
do
{
//---read the incoming data---
//-- check if nws has data to be read
if (nws.DataAvailable){
int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize);
totalBytes += bytesRead;
//---write the byte() array into the memory stream---
s.Write(data, 0, bytesRead);
counter += 1;
}
//Loop Until totalBytes >= SIZEOFIMAGE
} while ( ! (totalBytes >= SIZEOFIMAGE));hope it helps
dhaim programming is a hobby that make some money as side effect :)
-
do
{
//---read the incoming data---
//-- check if nws has data to be read
if (nws.DataAvailable){
int bytesRead = nws.Read(data, 0, client.ReceiveBufferSize);
totalBytes += bytesRead;
//---write the byte() array into the memory stream---
s.Write(data, 0, bytesRead);
counter += 1;
}
//Loop Until totalBytes >= SIZEOFIMAGE
} while ( ! (totalBytes >= SIZEOFIMAGE));hope it helps
dhaim programming is a hobby that make some money as side effect :)
Hi Mbah, I finally got it working. However, I notice that I am reading nothing at all. When I call client.ReadBufferSize, it returned 0 in windows mobile but 8167 in windows (which 8167 is the datasize I set for server sending information to this program). Any suggestions ?