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. NetworkStream, possibly Read timeout?

NetworkStream, possibly Read timeout?

Scheduled Pinned Locked Moved C#
helpquestion
1 Posts 1 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.
  • T Offline
    T Offline
    Trapper Hell
    wrote on last edited by
    #1

    I have these two applications, one of which sends a screenshot image to the other. This works smoothly on most PCs, however some (older) PCs start receiving a lot of zeros after reading some of the data. How can I ensure that all the data being sent, is read? I don't know if this is a timeout issue, or what? (I have found some solutions, such as WriteByte / ReadByte, but I need it to perform quite fast too, if possible) The methods are as follows: Sending:

    if (nsStream.CanWrite)
    nsStream.Write(bUp, 0, bUp.Length);

    nsStream.Flush();

    int x = 0;

    while (nsStream.DataAvailable && x < dataReadWait)
    {
    x++;
    // Wait for data to be read
    }

    return true;

    Receiving:

    if (nsStream.CanRead)
    nsStream.Read(bDown, 0, bDown.Length);

    nsStream.Flush();
    return bDown;

    At this point, it is worth saying that the Sender prior to sending the actual image, sends the length of the image (which is assigned to bDown), that is why data is read until the length of bDown... Any help is so greatly appreciated!

    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