Re: JxtaSocket question

[email protected] Mon, 11 Dec 2006 13:44:53 +0100
Newsgroups gmane.comp.java.jxta.user
Message-ID <[email protected]>
Make sure you really flush your OutputStreams, and then make sure to 
listen to the end of a stream:

int BUFSIZE = 2048; // 2kb, I don't know which buffer size works best
int offset = 0;
int len = 0;
boolean EOS = false; // End of stream
byte[] buf = new byte[BUFSIZE];

// receive header and data
while ((offset < BUFSIZE) && (!EOS)) {
    len = this.socketis.read(buf, offset, BUFSIZE - offset);
    if (len < 1) {
        EOS = true;
    }

    offset += len;

    // process received data here ..........
}

I hope this helped!?
Vince



Rodney Eng wrote:
> Thanks for all the help on my last problem, deleting the CM solved a 
> lot of my initial problems with JXTA.
>
> However, I've been trying to get JxtaSockets working now (I had been 
> using regular Unicast Pipes to send files, but I wanted to start 
> sending things larger than 64 KB reliably--though, I was able to get 
> 200 KB messages across a few times), but I've got a problem.  I have 
> peer A set up a JxtaServerSocket and wait for connection from peer B.  
> They connect alright, and peer A begins sending the file to peer B.  
> However, when A flushes and then closes the socket, peer B doesn't 
> seem to finish getting the data, and even in cases where peer B 
> appears to have gotten the whole file, it seems to never realize that 
> the file has finished coming across and just sort of hangs there.
>
> Am I missing something obvious?
>
> - Rodney Eng