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. Sending byte arrays using sockets

Sending byte arrays using sockets

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • S Offline
    S Offline
    Steven M Hunt
    wrote on last edited by
    #1

    Hello. For a project i am currently working on, i need to be able to send data, images specificly, between computers using sockets. Unfortunately, i have had some diffuculty making tcp transfer the data. I've been trying to use NetworkStream.read() and NetworkStream.write(), but for some reason the image always gets messed up in transfer. I tried sending the data in 32 byte bursts, but the image still arrives with serious errors in it. What is the fastest and most reliable way to send byte arrays across computers, preferably with streams? P.S. a few lines of code would be extremely helpful -- Steven Hunt

    J N 2 Replies Last reply
    0
    • S Steven M Hunt

      Hello. For a project i am currently working on, i need to be able to send data, images specificly, between computers using sockets. Unfortunately, i have had some diffuculty making tcp transfer the data. I've been trying to use NetworkStream.read() and NetworkStream.write(), but for some reason the image always gets messed up in transfer. I tried sending the data in 32 byte bursts, but the image still arrives with serious errors in it. What is the fastest and most reliable way to send byte arrays across computers, preferably with streams? P.S. a few lines of code would be extremely helpful -- Steven Hunt

      J Offline
      J Offline
      Jun Du
      wrote on last edited by
      #2

      Search CP for "tcp" filtered by C# and you'll get tons of artciles. Best, Jun

      1 Reply Last reply
      0
      • S Steven M Hunt

        Hello. For a project i am currently working on, i need to be able to send data, images specificly, between computers using sockets. Unfortunately, i have had some diffuculty making tcp transfer the data. I've been trying to use NetworkStream.read() and NetworkStream.write(), but for some reason the image always gets messed up in transfer. I tried sending the data in 32 byte bursts, but the image still arrives with serious errors in it. What is the fastest and most reliable way to send byte arrays across computers, preferably with streams? P.S. a few lines of code would be extremely helpful -- Steven Hunt

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Hello I've already been sending images across LAN networks using sockets, but strangely I didn't face your problem!!:confused: Your post raises some points: 1- Try checking your method of sending data. Do you send other data than images? Are there any problems in any of the other types? 2-Are you sure you are reading the bytes of the image corectly? Try after reading the data, and just before sending it using the NetworkStream, try to convert it back to Image, see if it works. 3- I have been converting my data from Bytes to strings using Encoding.Default.GetString() method before sending them across the NetworkStream, maybe you would like to try this 4- If you still having problems try to use the Socket.Send() and Socket.Reveive() methods instead?? perhaps??:^) I hope this was helpful.

        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