int send(
final DatagramChannel datagramChannel,
final ByteBuffer buffer,
final SendChannelEndpoint channelEndpoint,
final int bytesToSend)
{
final long nowNs = nanoClock.nanoTime();
final ArrayList<Destination> destinations = this.destinations;
final int position = buffer.position();
int minBytesSent = bytesToSend;
for (int lastIndex = destinations.size() - 1, i = lastIndex; i >= 0; i--)
{
final Destination destination = destinations.get(i);
if (nowNs > (destination.timeOfLastActivityNs + destinationTimeoutNs))
{
ArrayListUtil.fastUnorderedRemove(destinations, i, lastIndex);
lastIndex--;
}
else
{
int bytesSent = 0;
try
{
channelEndpoint.presend(buffer, destination.address);
buffer.position(position);
bytesSent = datagramChannel.send(buffer, destination.address);
}
catch (final PortUnreachableException | ClosedChannelException ignore)
{
}
catch (final IOException ex)
{
throw new RuntimeException("Failed to send packet of length: " + bytesToSend, ex);
}
minBytesSent = Math.min(minBytesSent, bytesSent);
}
}
return minBytesSent;
}
MultiDestination.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:aeron
作者:
评论列表
文章目录