Tristan McHardie

Greenhorn
+ Follow
since Feb 26, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tristan McHardie

I have a thread which is started when its outer class is instantiated. At any given time, this thread likely to be blocked by a DatagramSocket.read() call, and it is in an infinite loop. I want to write a method called close() which, among other things, will kill this thread. My first thought was for the loop condition to be an instance variable which could be modified. Naturally, this cannot be the case as if the thread has been blocked, it may never get back to test this variable (and subsequently break the loop).

Is there a way to cause a thread to stop what its doing and go into a cleanup routine?
Hi, thanks for the help!

My next problem should probably be in the begginner forum, but I'll keep it in this thread as it's directly related to it.

The send() method below is an overriding method, which adds TCP-like reliability to a UDP socket. After the headers have been added, I need to call super.send() to pass the reliable packet to the unreliable socket.

My question is, how do I call super.send() from within the TimerTask, which is obviously a subclass?

Thanks,
Tristan

18 years ago
I am writing an application that provides reliable network transport over a deliberately unreliable socket (it is a university assignment). At this stage it is just a stop-and-wait protocol. I want to have two events that can trigger a resend:

* timeout event
* incorrectly numbered ack received

My question is, how do I start a timer and have either Unreliabe.receive() or a timeout event trigger a resend? Two events that cause one action.
18 years ago
This post should probably be in the Sockets forum as well...

I'm writing a server that will need to run on both Windows and Linux machines, with clients from both platforms as well. The clients use the standard Microsoft and GNU telnet clients.

The server waits for incoming connections and creates new sockets in the standard way, i.e.



I'm just confused as to which buffers/readers/writers I should be using on top of the socket's input and output streams to read/write lines of text to/from the clients.

I've tried a few approaches, but when the Microsoft client works well, the GNU client appends ^M each time I press Enter. I know this has something to do with MS using \n\r where *nix uses plain old \n, but how do I work around this in my server?
18 years ago
Thanks alot, works perfectly now
18 years ago
This is the start of a program which uses a tree to represent a part of the filesystem.

I'm having trouble with the Iterator's next() method. When I call it.next(), the class of the object returned is java.io.File, even though the ArrayList it is iterating is <Directory>. I know Directory is a subclass of File (afterall, I created it) but why is it casting it back to a file in the iterator?

Here is the code for the Directory class:



Here is the code for the tree (where the problem is):



Here is my main application:



Thanks for any suggestions!
18 years ago