124 |
if (isClosed()) |
if (isClosed()) |
125 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
126 |
|
|
127 |
return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF); |
return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF); |
128 |
} |
} |
129 |
|
|
130 |
/** |
/** |
148 |
// Use getTTL here rather than getTimeToLive in case we're using an impl |
// Use getTTL here rather than getTimeToLive in case we're using an impl |
149 |
// other than the default PlainDatagramSocketImpl and it doesn't have |
// other than the default PlainDatagramSocketImpl and it doesn't have |
150 |
// getTimeToLive yet. |
// getTimeToLive yet. |
151 |
return impl.getTTL(); |
return getImpl().getTTL(); |
152 |
} |
} |
153 |
|
|
154 |
/** |
/** |
166 |
if (isClosed()) |
if (isClosed()) |
167 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
168 |
|
|
169 |
return impl.getTimeToLive(); |
return getImpl().getTimeToLive(); |
170 |
} |
} |
171 |
|
|
172 |
/** |
/** |
183 |
if (isClosed()) |
if (isClosed()) |
184 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
185 |
|
|
186 |
impl.setOption(SocketOptions.IP_MULTICAST_IF, addr); |
getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr); |
187 |
} |
} |
188 |
|
|
189 |
/** |
/** |
206 |
Enumeration e = netIf.getInetAddresses (); |
Enumeration e = netIf.getInetAddresses (); |
207 |
|
|
208 |
if (!e.hasMoreElements ()) |
if (!e.hasMoreElements ()) |
209 |
throw new SocketException ("MulticastSocket: Error"); |
throw new SocketException("no network devices found"); |
210 |
|
|
211 |
InetAddress address = (InetAddress) e.nextElement (); |
InetAddress address = (InetAddress) e.nextElement (); |
212 |
impl.setOption (SocketOptions.IP_MULTICAST_IF, address); |
getImpl().setOption (SocketOptions.IP_MULTICAST_IF, address); |
213 |
} |
} |
214 |
|
|
215 |
/** |
/** |
230 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
231 |
|
|
232 |
InetAddress address = |
InetAddress address = |
233 |
(InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF); |
(InetAddress) getImpl().getOption (SocketOptions.IP_MULTICAST_IF); |
234 |
NetworkInterface netIf = NetworkInterface.getByInetAddress (address); |
NetworkInterface netIf = NetworkInterface.getByInetAddress (address); |
235 |
|
|
236 |
return netIf; |
return netIf; |
255 |
if (isClosed()) |
if (isClosed()) |
256 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
257 |
|
|
258 |
impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable)); |
getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable)); |
259 |
} |
} |
260 |
|
|
261 |
/** |
/** |
270 |
if (isClosed()) |
if (isClosed()) |
271 |
throw new SocketException("socket is closed"); |
throw new SocketException("socket is closed"); |
272 |
|
|
273 |
Object obj = impl.getOption (SocketOptions.IP_MULTICAST_LOOP); |
Object buf = getImpl().getOption (SocketOptions.IP_MULTICAST_LOOP); |
274 |
|
|
275 |
if (obj instanceof Boolean) |
if (buf instanceof Boolean) |
276 |
return ((Boolean) obj).booleanValue (); |
return ((Boolean) buf).booleanValue(); |
277 |
else |
|
278 |
throw new SocketException ("Unexpected type"); |
throw new SocketException("unexpected type"); |
279 |
} |
} |
280 |
|
|
281 |
/** |
/** |
298 |
// Use setTTL here rather than setTimeToLive in case we're using an impl |
// Use setTTL here rather than setTimeToLive in case we're using an impl |
299 |
// other than the default PlainDatagramSocketImpl and it doesn't have |
// other than the default PlainDatagramSocketImpl and it doesn't have |
300 |
// setTimeToLive yet. |
// setTimeToLive yet. |
301 |
impl.setTTL(ttl); |
getImpl().setTTL(ttl); |
302 |
} |
} |
303 |
|
|
304 |
/** |
/** |
319 |
if (ttl <= 0 || ttl > 255) |
if (ttl <= 0 || ttl > 255) |
320 |
throw new IllegalArgumentException("Invalid ttl: " + ttl); |
throw new IllegalArgumentException("Invalid ttl: " + ttl); |
321 |
|
|
322 |
impl.setTimeToLive(ttl); |
getImpl().setTimeToLive(ttl); |
323 |
} |
} |
324 |
|
|
325 |
/** |
/** |
343 |
if (s != null) |
if (s != null) |
344 |
s.checkMulticast(mcastaddr); |
s.checkMulticast(mcastaddr); |
345 |
|
|
346 |
impl.join(mcastaddr); |
getImpl().join(mcastaddr); |
347 |
} |
} |
348 |
|
|
349 |
/** |
/** |
367 |
if (s != null) |
if (s != null) |
368 |
s.checkMulticast(mcastaddr); |
s.checkMulticast(mcastaddr); |
369 |
|
|
370 |
impl.leave(mcastaddr); |
getImpl().leave(mcastaddr); |
371 |
} |
} |
372 |
|
|
373 |
/** |
/** |
406 |
if (s != null) |
if (s != null) |
407 |
s.checkMulticast (tmp.getAddress ()); |
s.checkMulticast (tmp.getAddress ()); |
408 |
|
|
409 |
impl.joinGroup (mcastaddr, netIf); |
getImpl().joinGroup (mcastaddr, netIf); |
410 |
} |
} |
411 |
|
|
412 |
/** |
/** |
441 |
if (s != null) |
if (s != null) |
442 |
s.checkMulticast (tmp.getAddress ()); |
s.checkMulticast (tmp.getAddress ()); |
443 |
|
|
444 |
impl.leaveGroup (mcastaddr, netIf); |
getImpl().leaveGroup (mcastaddr, netIf); |
445 |
} |
} |
446 |
|
|
447 |
/** |
/** |
475 |
s.checkConnect(addr.getHostAddress(), p.getPort()); |
s.checkConnect(addr.getHostAddress(), p.getPort()); |
476 |
} |
} |
477 |
|
|
478 |
int oldttl = impl.getTimeToLive(); |
int oldttl = getImpl().getTimeToLive(); |
479 |
impl.setTimeToLive(((int) ttl) & 0xFF); |
getImpl().setTimeToLive(((int) ttl) & 0xFF); |
480 |
impl.send(p); |
getImpl().send(p); |
481 |
impl.setTimeToLive(oldttl); |
getImpl().setTimeToLive(oldttl); |
482 |
} |
} |
483 |
} // class MulticastSocket |
} // class MulticastSocket |