Results 1 to 11 of 11
Thread: byte[]
- 09-10-2010, 10:40 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 37
- Rep Power
- 0
-
- 09-10-2010, 11:00 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 37
- Rep Power
- 0
I think it's different. could you please help me?
- 09-10-2010, 11:21 PM #4
Can you do some debugging with your code to identify how the byte[] is not being sent properly? Are all the bytes sent being received? If 33 are sent are 33 bytes received? Is there one or more bytes that are received with different values than they were sent as?
What is the value of the byte and what is its position in the array?
For example the 17th byte was sent as a 0x83 and received as a 0x3F
- 09-11-2010, 02:14 AM #5
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 12
post your code where the problem is happening
- 09-11-2010, 08:13 AM #6
Member
- Join Date
- Sep 2010
- Posts
- 37
- Rep Power
- 0
here's the code
Java Code://client { Socket skt = new Socket("localhost", 4444); System.out.print("Socket is open."); OutputStream out = skt.getOutputStream(); DataOutputStream dout = new DataOutputStream(out); dout.write([COLOR="Red"]M1e[/COLOR], 0, 48); System.out.print(M1e+ "sent"); out.close(); } //server { byte[] bytes = new byte[65536]; Socket skt = srvr.accept(); System.out.print("Server has connected!\n"); InputStream ins = skt.getInputStream(); DataInputStream din = new DataInputStream(ins); din.read([COLOR="Red"]bytes[/COLOR]); System.out.print("Received"); System.out.println(bytes); }
Last edited by bobo67; 09-11-2010 at 02:59 PM.
-
When posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
- 09-11-2010, 09:20 AM #8
Member
- Join Date
- Sep 2010
- Posts
- 37
- Rep Power
- 0
-
You are currently seeing the toString representation of an array, and while the two array addresses are different as to be expected, this tells you nothing about the array contents other than they are both arrays of bytes.
- 09-11-2010, 09:39 AM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
- 09-11-2010, 03:06 PM #11
Similar Threads
-
Streaming an image byte by byte (and similtaneosly rendering it on screen)
By ea25 in forum New To JavaReplies: 1Last Post: 04-21-2010, 03:28 AM -
Byte Ranges
By alessandro_ in forum NetworkingReplies: 2Last Post: 02-14-2010, 12:48 PM -
Byte class ?
By Hardik in forum New To JavaReplies: 1Last Post: 07-20-2009, 04:34 PM -
Byte Array
By sandor in forum New To JavaReplies: 12Last Post: 01-15-2009, 04:31 AM -
int to byte
By ravian in forum New To JavaReplies: 1Last Post: 01-13-2008, 08:22 PM
Bookmarks