Sending the same tcp message to multiple destinations/hosts in a single context switch

Thang Le thangmle at gmail.com
Sun Aug 30 03:10:27 UTC 2015


Hi all,

I need to send/fan-out the same message to a list of hosts through tcpip
sockets efficiently. The logic would require looping through each socket to
write the message out. If this logic runs in the linux user mode, the
underlying OS will call the system call as many times as the number of
hosts. This is expensive since each system call requires user-mode to
kernel-mode context switch.

It would be more efficient if the loop can be moved to a system call that
takes a list of hosts (file descriptors). Does such system call exist in
linux?

If it does, do we have an equivalent API in Java (similar to transferTo()
in Java corresponds to sendfile() in linux)?

Thanks,
Thang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20150829/03bd886b/attachment.html>


More information about the nio-discuss mailing list