Hi Bob
I faced the same problem and solve it using below solution :
options.add(new Inet.AbstractSocketOption() {
/**
* from file /usr/include/asm-generic/socket.h
* #define SO_REUSEPORT 15
*/
private final static int SO_REUSEPORT = 15;
private final static int SOL_SOCKET = 1;
@Override
public void beforeDatagramBind(DatagramSocket ds) {
setReusePort(ds.getChannel());
}
public void setReusePort(DatagramChannel datagramChannel) {
try {
Field fieldFd =
datagramChannel.getClass().getDeclaredField("fd");
//NoSuchFieldException
fieldFd.setAccessible(true);
FileDescriptor fd = (FileDescriptor)
fieldFd.get(datagramChannel);
//IllegalAccessException
//JDK 1.8.0_66
//Method methodSetIntOption0 =
Net.class.getDeclaredMethod("setIntOption0", FileDescriptor.class,Boolean.TYPE,
Integer.TYPE, Integer.TYPE, Integer.TYPE, Boolean.TYPE);
//JDK 1.8.0_31
Method methodSetIntOption0 =
Net.class.getDeclaredMethod("setIntOption0", FileDescriptor.class,
Boolean.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
methodSetIntOption0.setAccessible(true);
//methodSetIntOption0.invoke(null, fd, false, 1,
SO_REUSEPORT, 1, true);
methodSetIntOption0.invoke(null, fd, false, SOL_SOCKET,
SO_REUSEPORT, 1);
} catch (Exception e) {
System.out.println(e.toString());
}
}
});
final ActorRef mgr = Udp.get(getContext().system()).getManager();
mgr.tell(UdpMessage.bind(getSelf(), new InetSocketAddress(host,
port), options), getSelf());
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.