Results 1 to 9 of 9
- 06-09-2012, 01:36 AM #1
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
What is the meaning of the char(0x00)?
Basically I've got a java server and a flash client
On the java code the is a var "char EOF = (char)0x00;" and when it sends a message to the client the code looks like this:
OUT.println("message what ever" + EOF);
The client receives it like this: (printed in client's console)
"message what ever
"
As you see there are multiple empty lines created.. I don't what that.. But when I remove the "+EOF" the client doesn't receive anything at all..
Help?Last edited by Lionlev; 06-09-2012 at 10:06 PM.
- 06-09-2012, 02:18 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,538
- Rep Power
- 11
Re: What is the meaning of the char(0x00)?
The value zero represents the number of things you have of some type when things of that type are, in fact, completely absent. As such it is a rather abstract (peculiar?) number - but it has its uses.
In Java code zero can be the value of any integral data type (long, int, char). Just a guess - without seeing any code - but it looks like zero is being sent to the client to mean "this is the end of the message".
Are you sure about that? Why?when I remove the "+EOF" the client doesn't receive anything at all.
More likely, the client receives the bytes OK. But you have removed the zero so the client never learns that "this is the end of the message", and, hence, never moves on to print the message.
-----
If you are new to Java (or programming) I would recommend being cautious about trying to hack about with existing, rather complex code. Learn the basics first, with code you design and write yourself. But who am I to say? - you know yourself best.
In any case as well as the code, I find I usually need to know the general "approach" (what the author hopes to achieve) being used before I can make head or tail of individual lines. And the "architecture" - in this case what a client and server *are* and how, in code, they communicate. In short when reading other people's code - and especially in unfamiliar territory - the documentation surrounding the code is vital and is the starting place. Without that documentation, I wouldn't bother.
- 06-09-2012, 12:43 PM #3
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
- 06-09-2012, 02:00 PM #4
Re: What is the meaning of the char(0x00)?
What class is the OUT object? What does its println method do when it tries to print a char with a value of 0?
If you don't understand my response, don't ignore it, ask a question.
- 06-09-2012, 09:00 PM #5
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
- 06-09-2012, 09:07 PM #6
Re: What is the meaning of the char(0x00)?
What does the client program do when it tries to display a String with a char = 0?
If you don't understand my response, don't ignore it, ask a question.
- 06-09-2012, 10:06 PM #7
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
- 06-09-2012, 10:27 PM #8
Re: What is the meaning of the char(0x00)?
I think every program can do something different when it prints a char = 0. Read the doc for the program or test the program with different char values to see what it does.
Another example is the tab character, every program that prints a tab character can do something different with it.If you don't understand my response, don't ignore it, ask a question.
- 06-10-2012, 12:28 PM #9
Senior Member
- Join Date
- May 2012
- Posts
- 170
- Rep Power
- 1
Similar Threads
-
check a string char by char
By Sotsiak in forum New To JavaReplies: 2Last Post: 10-23-2010, 09:24 PM -
replaceALL(char oldChar, char newChar) method
By arson09 in forum New To JavaReplies: 0Last Post: 04-28-2010, 05:48 AM -
for loop meaning
By ahmakki in forum New To JavaReplies: 3Last Post: 04-12-2010, 01:06 AM -
drawing char by char with Graphics
By diggitydoggz in forum New To JavaReplies: 5Last Post: 12-27-2008, 12:49 PM -
Exception:Meaning
By tiger100plus in forum New To JavaReplies: 2Last Post: 11-27-2008, 07:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks