Results 1 to 2 of 2
- 08-19-2011, 05:13 PM #1Member
- Join Date
- Feb 2011
- Rep Power
SocketClient is reading line with an end of line byte in it?
Hello, so far my application has worked perfectly. The server sending a line that is terminated by the '\n' character. The client then read's the line stopping at the '\n' character. Now my issue is that I am sending an image over the connection. At index 43 of the image's byte array there is a "10" which converted to ASCII is the '\n' character. So how can I send the '\n' that is inside the array without having it trigger the end of line?
- 08-19-2011, 07:29 PM #2
That's a problem with using a binary value as the end of record marker. Image files can have any of the 256 possible values for its bytes. You need to come up with a different protocol.
For example send a lead byte in each transmission that says what type of data follows.
For text the data would be terminated by a '\n' character
For binary, the data would be preceded by a length field specifying the number of bytes that follow.
- By Nazneen Ali in forum New To JavaReplies: 7Last Post: 07-20-2011, 07:56 AM
- By trkece in forum New To JavaReplies: 1Last Post: 02-13-2011, 04:09 PM
- By dricco in forum New To JavaReplies: 2Last Post: 07-02-2010, 02:20 PM
- By guru32 in forum New To JavaReplies: 9Last Post: 04-07-2009, 03:51 AM
- By bluekswing in forum New To JavaReplies: 1Last Post: 10-02-2007, 12:19 AM