Computer Science Canada

Sockets and Threads

Author:  matt271 [ Sun May 03, 2009 8:38 am ]
Post subject:  Sockets and Threads

i want to make a download accelerator in java.
i need to open several sockets at one time and retrieve data from them. the problem is when i read from a socket it blocks until all the data is received.
like:

// got to here at some time
blah.read(blah);
// finished here at some later time

i want something like:

// got to here at some time
blah.istheredatayet?
// finished here at ~ same time

so i dont have to open new threads for each socket

is this possible?

Author:  OneOffDriveByPoster [ Mon May 04, 2009 9:40 pm ]
Post subject:  Re: Sockets and Threads

matt271 @ Sun May 03, 2009 8:38 am wrote:

so i dont have to open new threads for each socket

is this possible?
I think the SocketChannel and Selector classes can help here.


: