I'm just sending this to the dev list for the record in case people want
to recreate the logic I went through...
[EMAIL PROTECTED] wrote:
> Log:
> Remove multicast socket native call, and replace it with regular
> datagram socket creation.
> The main difference here is that the setting of SO_REUSEADDR will be
> called for sockets created from a user defined datagram socket factory
> (it wasn't previously). Since we need the option set, this is a good
> thing.
<snip>
> - // the required default options are now set in the VM where they
> - // should be
> + impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.TRUE);
I figured this out by creating a mock socket impl and seeing what calls
were made on it from the RI, which were:
constructor
create
setOption id: 4 val:true
bind
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.DatagramSocketImpl;
import java.net.DatagramSocketImplFactory;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketException;
public class TestDGSocket {
private static class FakeSock extends DatagramSocketImpl {
public FakeSock() { System.out.println("constructor"); }
protected void bind(int lport, InetAddress laddr) throws
SocketException { System.out.println("bind"); }
protected void close() { System.out.println("close"); }
protected void create() throws SocketException {
System.out.println("create"); }
protected byte getTTL() throws IOException {
System.out.println("getTTL"); return 0; }
protected int getTimeToLive() throws IOException {
System.out.println("getTimeToLive"); return 0; }
protected void join(InetAddress inetaddr) throws IOException {
System.out.println("join"); }
protected void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf) throws IOException {
System.out.println("joinGroup"); }
protected void leave(InetAddress inetaddr) throws IOException {
System.out.println("leave"); }
protected void leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf) throws IOException {
System.out.println("leaveGroup"); }
protected int peek(InetAddress i) throws IOException {
System.out.println("peek"); return 0; }
protected int peekData(DatagramPacket p) throws IOException {
System.out.println("peekData"); return 0; }
protected void receive(DatagramPacket p) throws IOException {
System.out.println("receive"); }
protected void send(DatagramPacket p) throws IOException {
System.out.println("send"); }
protected void setTTL(byte ttl) throws IOException {
System.out.println("setTTL"); }
protected void setTimeToLive(int ttl) throws IOException {
System.out.println("setTimeToLive"); }
public Object getOption(int optID) throws SocketException {
System.out.println("getOption"); return null; }
public void setOption(int optID, Object value) throws
SocketException { System.out.println("setOption id: " + optID + " val:"
+ value); }
}
public static void main(String[] args) throws IOException {
DatagramSocketImplFactory factory = new
DatagramSocketImplFactory() {
public DatagramSocketImpl createDatagramSocketImpl() {
return new FakeSock();
}
};
DatagramSocket.setDatagramSocketImplFactory(factory);
MulticastSocket s = new MulticastSocket();
System.out.println(s);
}
}