Whenever I put something within my try-catch blocks, I get this error "cannot find symbol" when I have already defined everything clearly for each try-catch blocks. None of the try catch blocks work, dunno why.
Unless you show us the code and the full error message it's hard to say what is wrong other than maybe you haven't declared a variable/method you are using or you haven't added an import statement you need.
I haven't looked - it's hard to read code that hasn't been formatted (hence we keep asking you to use code tags). And I don't have the time at the moment so you'll just have to run it and see if it works.
Oh ya, I din realise earlier, was so caught up in fixing my exceptions. Basically, I need time-stamps to check that curr time doesn differ from the time-stamp time by more than 1 min & if it does to retransmit data. I m not sure how to reestablish connection to retransmit data, do I create a new socket for connection re-establishment? Since m implementing a simplified Kerberos protocol, m not sure how to handle the creation of challenges either. Coding on Kerberos seems to be very little on the net, in fact I can hardly find exaamples. If u have knowledge on Kerberos pls share, tks.
Just a small point on exception handling Susan, that will make coding simpler and the finished code clearer...
The try...catch structure is designed to allow you to write the bulk of your code without worrying about the errors until the end of the method. So you should open a single 'try' block, write all the method code, then catch all the errors at the end, e.g.:
Code:
public void aMethod {
// declare variables that may need tidying up after errors
...
try {
// initialise variables
...
// put main body of method code here, ignoring exceptions
...
...
}
// now the main work has been done, handle any problems that may have occurred
catch (ExceptionA a) {
... // handle a
}
catch (ExceptionB b) {
... // handle b
}
finally {
... // tidy up variables, close handles, etc.
}
} // end of method
Sometimes you may want to handle an exception and carry on, in which case you could just nest a single try..catch in the body of the code, but the preferred way is to put that piece of code into it's own method so its try..catch is hidden from the main code. This keeps the code body clear of messy exception handling, and ensures all methods follow the same 'single try, multiple catch' formula.
It's only a guideline, but it is Best Practice
Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves...
Alan Kay
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
If you get an error, please post the full error message and stack trace, if present.
Incidentally, socket1 on the server has been declared but hasn't been initialised.
Optimism is an occupational hazard of programming; feedback is the treatment...
Kent Beck
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Ok, I changed my code, now since m sending strings from client to server, I want to know how I can send multiple strings to server. Eg. If client types hello then server echoes hello, then client types world server should echo world & it sholuld continue until client stops so how to send multiple strings in java?
You need the server code to loop back to waiting for the client after it handles the client message, and the client to loop round and send a new message after every server acknowledgement.
I can't say more without seeing the relevant code.
Programs must be written for people to read, and only incidentally for machines to execute...
Abelson and Sussman
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Bookmarks