내가 디버그 코드를 안드로이드에 SocketChannel 쓰기가 포함되어있어, 내가 IllegalArgumentException있어,하지만 Windows 에서이 코드는 동일한 안드로이드와 SocketChannel에서 Windows의 차이점은 무엇입니까?은 Android에서 Java SocketChannel 쓰기 (ByteBuffer 소스)가 Windows에서 다른가요?
UPDATE : (코드의 일부 오픈 소스 프로젝트 frostwire - 안드로이드 (this file in github),이 부분은 그냥 시도 {} 추가 Vuze를 4.5과 동일)
private int channelWrite(ByteBuffer buf) throws IOException
{
int written = 0;
while(remainingBytesToScatter > 0 && buf.remaining() > 0)
{
int currentWritten = 0;
try{
currentWritten = channel.write((ByteBuffer)(buf.slice().limit(Math.min(50+rnd.nextInt(100),buf.remaining()))));
}catch(Exception e) {
if(e instanceof IOException) {
Log.d("", "chanel write IOException " + e.getMessage());
}else if(e instanceof IOException) {
Log.d("", "chanel write AsynchronousCloseException " + e.getMessage());
}else if(e instanceof ClosedByInterruptException) {
Log.d("", "chanel write ClosedByInterruptException " + e.getMessage());
}else if(e instanceof ClosedChannelException) {
Log.d("", "chanel write ClosedChannelException " + e.getMessage());
}else if(e instanceof NotYetConnectedException) {
Log.d("", "chanel write ClosedChannelException " + e.getMessage());
}else {
// while in second time, reach here
Log.d("", "chanel write unknown " + e.getMessage());
}
}
if(currentWritten == 0)
break;
buf.position(buf.position()+currentWritten);
remainingBytesToScatter -= currentWritten;
if(remainingBytesToScatter <= 0)
{
remainingBytesToScatter = 0;
try
{
channel.socket().setTcpNoDelay(false);
} catch (SocketException e)
{
Debug.printStackTrace(e);
}
}
written += currentWritten;
}
if(buf.remaining() > 0)
written += channel.write(buf);
return written;
}