kay lin

Ranch Hand
+ Follow
since May 20, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kay lin

does anyone actually know the deadline for taking SCJP 1.4?
seems to be fine now..
thanks guys

REALLY APPRECIATE IT..
ok, i ran the app with socket.connect(addr,port)

i got the following error

java.net.SocketException: already connected
at java.net.Socket.connect(Socket.java:497)



So does that mean that connect is reduandent???
here is the thing though.
the server is starting at port 3000 on another host, a separate box..
i don't think anythign else is using port 3000...if it is , it shouldn't.

I just did netstat -a | grep 3000, and it is only my server that is on port 3000


Here is the Server portion of the code that is running on the server box


So, what should the client portion of the code be ? shouldn't it be something like this



My question is , should i call socket.connect() at all??
because in the tutorial http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html
they did not call the connect on the client..they just get the IO streams directly..

Please let me know what I am doing wrong...

All helps are greatly appreciated...!!
Ah!!!
it turns out that I cann't call bind() before accept, it throws BindException..damn..

The thing is my server is running on another box...

so if I just try ServerSocket ss = new ServerScoket(port);

what if something is running on the same port locally...?? well..i dont have anything running locally..so i am gonna try this one anyways..

sigh **

I need help!!
Hi,
so you are suggesting the server port is not listening?

could i try the following then



it is ok if i call bind() before accept()right?
Hi:
In my app, I am having problem connecting via the socket, here is a portion of my code



basically i tried a couple of values of timeout, i tried to make timeout bigger, but that didn't help , apparently....I kept on getting
java.net.ConnectException: Connection refused: connect


I am wondering if i could call Socket.bind() before connect?

Or I should just try

Socket socket = new Socket(host, port) ;
instead of Socekt socket = new Socket();

Please let me know.

Many thanks
Hi:
what exactly can you syncrhonize on? I have always thought we could synchronize on reference variables..

however, as I did some practice exam, I realize that you can also syncrhonize on expression that produces reference variable.

so can someone clearly tell me what are the rules for syncrhonized(expression)?

thanks..
Hi:
I am doing one of the practice questions on Thread, and here is a question i encountered



The answer is B. I think the reason C is incorrect is because when you have a local variable that refers to an instance that is created within the method, everytime a thread is created, it also creates the instance in the method , hence every thread has one instance and its lock, since defeat the purpose of syncrhonization.

Am I correct? please let me know.

Thanks
Hi:
I really need some help to get some good tips to prepare for my SCJP exam. I have currently finished reading all the chapters and did all the drill questions. however, the thing is I am also working full time so really the only time i have to study for the exam is on the weekends....and one big problem i find is that i tend to forget some of the materials I have studied and read before. I plan to take the exam no later than January. So it means I really need to get some quality study.

Can someone please share with me their tips and experience in preparing for this exam? I certainly don't expect it to be easy.
I am starting review all the chapters, make notes, and do practice questions......but I still somehow feel that I am not doing it effectively.

I'd really would like to hear from everyone so that I will succeed.

Thanks in advance.
Hey:
i was just running through some practice questions regarding the Thread chapter, which also happens to be the last chapter of the SCJP 1.4 exam.

however, I run in some questions related to Daemon thread..i did a bit of research online and was able to answer the questions...But then again, I realize that daemon thread i not covered in the K&B book..

so I am just wondering for those of you who have taken the SCJP 1.4 exam, have you seen any questions regarding daemon thread?

Pleae do let me know.

Thanks
what exactly do you mean by "more specific" sorry I am sitll not clear on that..
Hi:
Here is one practice quesiton I came upon

What is the result of attempting to compile and run the program?
a. Prints: float,float
b. Prints: float,double
c. Prints: double,float
d. Prints: double,double
e. Compile-time error
f. Run-time error
g. None of the above

The answer key is a. Prints: float,float

now, is it because on method invocation, the parameter of the invocating method can only be widened to match the parameters of the actual method?

please let me know.

Thanks
I was looking at the answers at one of the pracitce questions
Answers
Take a look at answer No.2,
I was confused as to what he meant by float is more "specific" than double..
Hi :
I was doing one of the practice exams and come across conversion.

Just wondering, is float more specific than double?

i think float is 32 bits and double is 64