I have to create a client/server system to stream video and audio. It would be very simple. Like youtube style. The server should attend clients providing a list of medias f
Check out the Java Media Framework (it has tutorials): http://java.sun.com/javase/technologies/desktop/media/jmf/
Does this even work?
while(true) {
Runnable r = new ThreadedEchoHandler(incoming, i);
Thread t = new Thread(r);
t.start();
i++;
}
I think your code would produce a bunch of threads with incoming socket connections... what you probably want to do is this:
while(true) {
Runnable r = new ThreadedEchoHandler(incoming.accept(), i);
Thread t = new Thread(r);
t.start();
i++;
}
The ThreadedEchoHandler should take a Socket instead of a ServerSocket. Accept blocks until a client connects, otherwise you'll be spawning an infinite number of threads without a connection... I don't think you have anything that will stop you from doing that at the moment.