Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. IOException 10054.

IOException 10054.

Scheduled Pinned Locked Moved C#
csharpsysadmindata-structureshelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leslie wu
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • L leslie wu

      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

      M Offline
      M Offline
      Mbah Dhaim
      wrote on last edited by
      #2

      add

      data = new byte[client.ReceiveBufferSize];

      before bold line hope it helps

      dhaim programming is a hobby that make some money as side effect :)

      L 1 Reply Last reply
      0
      • M Mbah Dhaim

        add

        data = new byte[client.ReceiveBufferSize];

        before bold line hope it helps

        dhaim programming is a hobby that make some money as side effect :)

        L Offline
        L Offline
        leslie wu
        wrote on last edited by
        #3

        Hi Mbah, I am still getting an error after inserting your line. Any more suggestions ? Thanks !

        M 1 Reply Last reply
        0
        • L leslie wu

          Hi Mbah, I am still getting an error after inserting your line. Any more suggestions ? Thanks !

          M Offline
          M Offline
          Mbah Dhaim
          wrote on last edited by
          #4

          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 :)

          L 1 Reply Last reply
          0
          • M Mbah Dhaim

            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 :)

            L Offline
            L Offline
            leslie wu
            wrote on last edited by
            #5

            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 ?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups