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