Hi all,
I’m using Smack in an open source peer-to-peer backup project
I’m having troubles negotiating streams.
Maybe it’s not the most appropriate method (please, let me know), but I’m using file transfers to negotiate I/O streams that I keep in a pool. I then use this pool to dispatch on a per need basis the backup/restore jobs.
I chose to do that since negotiation is a time consuming step. Besides my problem really comes from the fact that Smack doesn’t give acces to both streams created (eg, OutgoingFileTransfer only gives the output stream), and I really need to be able to read & write during a file backup negotiation.
I have created a main class SocketNegotiationManager that handles streams negotiation.
It implements FileTransferListener to receive incoming requests, and has a background thread to negotiation outgoing transfers. The principle is the following: for each incoming request, a peer starts an outgoing transfer negotiation in order to create a complete pair input + output streams.
The class SocketNegotiationManager combines (with a unique ID) an output and an input streams, and links them in a single BiSocket class that I can use to negotiate backup jobs.
My problem is that retrieving the input stream blocks and I almost always get an ExecutionException in the FutureTask from the method recieveFile() in IncomingFileTransfer:
InputStream is = request.accept().recieveFile();
My class SocketNegotiationManager is available here:
http://p2pbackupsmile.svn.sourceforge.net/viewvc/p2pbackupsmile/org.p2pbackup.ja bber/src/org/p2pbackup/sockets/SocketNegotiationManager.java?revision=102&view=m arkup
Honestly, I’ve been facing this issue several times and I can’t seem to find a way out this time…
Help / suggestions are very very welcome !
Thanks in advance
Raphaël