I need some suggestion on how to push an end of stream character without having to have sc.shutdownOutput() call being made on the server side after finish sending a file over the socket channel.
Here is the bit from server side
long curnset = 0l;
long temp = 0l;
int maxCount = 8192 * 1024;
logger.debug(AUDIT, "begin sending {}", filenameSize);
while (curnset < fsize)
{
temp = inChannel.transferTo(curnset, maxCount, sc);
curnset += temp;
logger.debug(AUDIT,"c {} | t {} | max {} | size {}",curnset,temp,maxCount,fsize);
}
logger.debug(AUDIT, "end sending {}", filenameSize);
Here is the client side:
logger.debug(AUDIT, "begin receiving {}", filenameSize);
while (curnset < this.fileSize)
{
logger.debug(AUDIT,"inside of while loop");
temp = outChannel.transferFrom(sc, curnset, maxCount);
curnset += temp;
logger.debug(AUDIT, "c {} | t {} | max {} | size {}", curnset, temp,
maxCount, this.fileSize);
}
logger.debug(AUDIT, "end receiving {}", filenameSize);
Here is how the program behaves: Server would complete its portion of code meanwhile the client would hang right at logger.debug(AUDIT,"inside of while loop"); Only when I ctrl-c the server side, the client would eventually complete that portion of code - but with missing bytes - around few thousand bytes shy of fileSize.
I have establish the fileSize for client and server. The same portion of code I use for sending a single file from server to client but with the difference in sc.shutdownOutput() -- if i call that, I can't resend another file through the same socket channel. I would like not to shutdown the output of socketchannel.
Any other way out of this?
Thanks in advance.