java.net.MulticastSocket翻译

类别:Java 点击:0 评论:0 推荐:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2-rc) on Fri Jun 13 00:14:24 PDT 2003 -->
<TITLE>
MulticastSocket (Java 2 Platform SE v1.4.2)
</TITLE>

<META NAME="keywords" CONTENT="java.net.MulticastSocket class">
<META NAME="keywords" CONTENT="setTTL()">
<META NAME="keywords" CONTENT="setTimeToLive()">
<META NAME="keywords" CONTENT="getTTL()">
<META NAME="keywords" CONTENT="getTimeToLive()">
<META NAME="keywords" CONTENT="joinGroup()">
<META NAME="keywords" CONTENT="leaveGroup()">
<META NAME="keywords" CONTENT="setInterface()">
<META NAME="keywords" CONTENT="getInterface()">
<META NAME="keywords" CONTENT="setNetworkInterface()">
<META NAME="keywords" CONTENT="getNetworkInterface()">
<META NAME="keywords" CONTENT="setLoopbackMode()">
<META NAME="keywords" CONTENT="getLoopbackMode()">
<META NAME="keywords" CONTENT="send()">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="MulticastSocket (Java 2 Platform SE v1.4.2)";
}
</SCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MulticastSocket.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.4.2</b></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../java/net/JarURLConnection.html" title="class in java.net"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../java/net/NetPermission.html" title="class in java.net"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MulticastSocket.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>

</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
java.net</FONT>
<BR>
Class MulticastSocket</H2>
<PRE>
<A HREF="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A>
  <IMG SRC="../../resources/inherit.gif" ALT="extended by"><A HREF="../../java/net/DatagramSocket.html" title="class in java.net">java.net.DatagramSocket</A>
      <IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>java.net.MulticastSocket</B>
</PRE>
<HR>
<DL>
<DT>public class <B>MulticastSocket</B><DT>extends <A HREF="../../java/net/DatagramSocket.html" title="class in java.net">DatagramSocket</A></DL>

<P>
The multicast datagram socket class is useful for sending
 and receiving IP multicast packets.  A MulticastSocket is
 a (UDP) DatagramSocket, with additional capabilities for
 joining "groups" of other multicast hosts on the internet.
 多播数据报套接字用于发送和接收IP多播包,一个MulticastSocket即一个
 DatagramSocket对象,具有加入互联网上多播主机组的能力。
 <P>
 A multicast group is specified by a class D IP address
 and by a standard UDP port number. Class D IP addresses
 are in the range <CODE>224.0.0.0</CODE> to <CODE>239.255.255.255</CODE>,
 inclusive. The address 224.0.0.0 is reserved and should not be used.
 一个多播组通过一个D类IP地址和一个标准的UDP端口来标识。D类IP地址的范围从
 224.0.0.0到239.255.255.255。地址224.0.0.0是个保留地址,不应该被使用。
 <P>
 One would join a multicast group by first creating a MulticastSocket
 with the desired port, then invoking the
 <CODE>joinGroup(InetAddress groupAddr)</CODE>
 method:
 加入一个多播组首先在希望的端口创建多播套接字,然后调用joinGroup(InetAddress groupAddr)方法:
 <PRE>
 // join a Multicast group and send the group salutations
 ...
 String msg = "Hello";
 InetAddress group = InetAddress.getByName("228.5.6.7");
 MulticastSocket s = new MulticastSocket(6789);
 s.joinGroup(group);
 DatagramPacket hi = new DatagramPacket(msg.getBytes(), msg.length(),
                             group, 6789);
 s.send(hi);
 // get their responses!
 byte[] buf = new byte[1000];
 DatagramPacket recv = new DatagramPacket(buf, buf.length);
 s.receive(recv);
 ...
 // OK, I'm done talking - leave the group...
 s.leaveGroup(group);
 </PRE>

 When one sends a message to a multicast group, <B>all</B> subscribing
 recipients to that host and port receive the message (within the
 time-to-live range of the packet, see below).  The socket needn't
 be a member of the multicast group to send messages to it.
 当一个套接字发送消息给多播组时,所有预定该主机和端口的接收者接收消息(在包的存活时间范围内,参看下面)。
 此套接字不必是发送信息给多播组的成员。
 <P>
 When a socket subscribes to a multicast group/port, it receives
 datagrams sent by other hosts to the group/port, as do all other
 members of the group and port.  A socket relinquishes membership
 in a group by the leaveGroup(InetAddress addr) method.  <B>
 Multiple MulticastSocket's</B> may subscribe to a multicast group
 and port concurrently, and they will all receive group datagrams.
 同组内其他成员一样,当一个套接字预订了一个多播组/端口,并通过这个组/端口接收其他主机发送的数据报。
 套接字通过leaveGroup(InetAddress addr)方法来离开一个组。多个多播套接字可以同时预定一个多播组和端口,并且它们
 都可以接收数据报。
 <P>
 Currently applets are not allowed to use multicast sockets.
 目前,applets不允许使用多播套接字。
<P>

<P>
<DL>
<DT><B>Since:</B></DT>
  <DD>JDK1.1</DD>
</DL>
<HR>

<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->


<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#MulticastSocket()">MulticastSocket</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a multicast socket.
创建一个多播套接字。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#MulticastSocket(int)">MulticastSocket</A></B>(int&nbsp;port)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a multicast socket and bind it to a specific port.
创建一个绑定在指定端口的多播套接字。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#MulticastSocket(java.net.SocketAddress)">MulticastSocket</A></B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;bindaddr)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a MulticastSocket bound to the specified socket address.
创建一个绑定在指定套接字地址的多播套接字。</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#getInterface()">getInterface</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Retrieve the address of the network interface used for
 multicast packets.
 获得多播套接字使用的网络接口地址。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#getLoopbackMode()">getLoopbackMode</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the setting for local loopback of multicast datagrams.
获得多播数据报的本地回环设置。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#getNetworkInterface()">getNetworkInterface</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the multicast network interface set.
获得多播网络的接口设置。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#getTimeToLive()">getTimeToLive</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the default time-to-live for multicast packets sent out on
 the socket.
 获得在套接字上发送的多播包的默认存活时间。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;byte</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#getTTL()">getTTL</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>use the getTimeToLive method instead, which returns
 an <b>int</b> instead of a <b>byte</b>. 代之以getTimeToLive方法,其返回int而不是byte。</I></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#joinGroup(java.net.InetAddress)">joinGroup</A></B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;mcastaddr)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Joins a multicast group.
加入一个多播组。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#joinGroup(java.net.SocketAddress, java.net.NetworkInterface)">joinGroup</A></B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;mcastaddr,
          <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Joins the specified multicast group at the specified interface.
用指定接口加入指定的多播组。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#leaveGroup(java.net.InetAddress)">leaveGroup</A></B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;mcastaddr)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Leave a multicast group.
离开一个多播组。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#leaveGroup(java.net.SocketAddress, java.net.NetworkInterface)">leaveGroup</A></B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;mcastaddr,
           <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Leave a multicast group on a specified local interface.
使指定接口离开多播组。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#send(java.net.DatagramPacket, byte)">send</A></B>(<A HREF="../../java/net/DatagramPacket.html" title="class in java.net">DatagramPacket</A>&nbsp;p,
     byte&nbsp;ttl)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>Use the following code or its equivalent instead:
使用下列代码或相当代码代替:
 ......
 int ttl = mcastSocket.getTimeToLive();
  mcastSocket.setTimeToLive(newttl);
 mcastSocket.send(p);
 mcastSocket.setTimeToLive(ttl);
 ......</I></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#setInterface(java.net.InetAddress)">setInterface</A></B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;inf)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the multicast network interface used by methods
 whose behavior would be affected by the value of the
 network interface.
 设置方法使用的多播网络接口,其工作情况将受接口值的影响。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#setLoopbackMode(boolean)">setLoopbackMode</A></B>(boolean&nbsp;disable)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Disable/Enable local loopback of multicast datagrams
 The option is used by the platform's networking code as a hint
 for setting whether multicast data will be looped back to
 the local socket.
 设置或取消多播数据报的本地回环,平台的网络代码使用此选择作为一个建议是否设置将多播数据回环到本地套接字。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#setNetworkInterface(java.net.NetworkInterface)">setNetworkInterface</A></B>(<A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specify the network interface for outgoing multicast datagrams
 sent on this socket.
 指定向此套接字上发送多播数据报的网络接口。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#setTimeToLive(int)">setTimeToLive</A></B>(int&nbsp;ttl)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the default time-to-live for multicast packets sent out
 on this <code>MulticastSocket</code> in order to control the
 scope of the multicasts.
 设置在此多播套接字发出的多播包的默认存活时间以便控制多播的作用域。</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../java/net/MulticastSocket.html#setTTL(byte)">setTTL</A></B>(byte&nbsp;ttl)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Deprecated.</B>&nbsp;<I>use the setTimeToLive method instead, which uses
 <b>int</b> instead of <b>byte</b> as the type for ttl.
 代之以setTimeToLive方法,其返回int而不是byte。</I></TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.net.DatagramSocket"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.net.<A HREF="../../java/net/DatagramSocket.html" title="class in java.net">DatagramSocket</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../java/net/DatagramSocket.html#bind(java.net.SocketAddress)">bind</A>, <A HREF="../../java/net/DatagramSocket.html#close()">close</A>, <A HREF="../../java/net/DatagramSocket.html#connect(java.net.InetAddress, int)">connect</A>, <A HREF="../../java/net/DatagramSocket.html#connect(java.net.SocketAddress)">connect</A>, <A HREF="../../java/net/DatagramSocket.html#disconnect()">disconnect</A>, <A HREF="../../java/net/DatagramSocket.html#getBroadcast()">getBroadcast</A>, <A HREF="../../java/net/DatagramSocket.html#getChannel()">getChannel</A>, <A HREF="../../java/net/DatagramSocket.html#getInetAddress()">getInetAddress</A>, <A HREF="../../java/net/DatagramSocket.html#getLocalAddress()">getLocalAddress</A>, <A HREF="../../java/net/DatagramSocket.html#getLocalPort()">getLocalPort</A>, <A HREF="../../java/net/DatagramSocket.html#getLocalSocketAddress()">getLocalSocketAddress</A>, <A HREF="../../java/net/DatagramSocket.html#getPort()">getPort</A>, <A HREF="../../java/net/DatagramSocket.html#getReceiveBufferSize()">getReceiveBufferSize</A>, <A HREF="../../java/net/DatagramSocket.html#getRemoteSocketAddress()">getRemoteSocketAddress</A>, <A HREF="../../java/net/DatagramSocket.html#getReuseAddress()">getReuseAddress</A>, <A HREF="../../java/net/DatagramSocket.html#getSendBufferSize()">getSendBufferSize</A>, <A HREF="../../java/net/DatagramSocket.html#getSoTimeout()">getSoTimeout</A>, <A HREF="../../java/net/DatagramSocket.html#getTrafficClass()">getTrafficClass</A>, <A HREF="../../java/net/DatagramSocket.html#isBound()">isBound</A>, <A HREF="../../java/net/DatagramSocket.html#isClosed()">isClosed</A>, <A HREF="../../java/net/DatagramSocket.html#isConnected()">isConnected</A>, <A HREF="../../java/net/DatagramSocket.html#receive(java.net.DatagramPacket)">receive</A>, <A HREF="../../java/net/DatagramSocket.html#send(java.net.DatagramPacket)">send</A>, <A HREF="../../java/net/DatagramSocket.html#setBroadcast(boolean)">setBroadcast</A>, <A HREF="../../java/net/DatagramSocket.html#setDatagramSocketImplFactory(java.net.DatagramSocketImplFactory)">setDatagramSocketImplFactory</A>, <A HREF="../../java/net/DatagramSocket.html#setReceiveBufferSize(int)">setReceiveBufferSize</A>, <A HREF="../../java/net/DatagramSocket.html#setReuseAddress(boolean)">setReuseAddress</A>, <A HREF="../../java/net/DatagramSocket.html#setSendBufferSize(int)">setSendBufferSize</A>, <A HREF="../../java/net/DatagramSocket.html#setSoTimeout(int)">setSoTimeout</A>, <A HREF="../../java/net/DatagramSocket.html#setTrafficClass(int)">setTrafficClass</A></CODE></TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ FIELD DETAIL =========== -->


<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="MulticastSocket()"><!-- --></A><H3>
MulticastSocket</H3>
<PRE>
public <B>MulticastSocket</B>()
                throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Create a multicast socket.
 创建一个多播套接字。
 <p>If there is a security manager,
 its <code>checkListen</code> method is first called
 with 0 as its argument to ensure the operation is allowed.
 This could result in a SecurityException.
 如果存在安全管理器,首先用0作为参数调用checkListen方法来确认操作是否允许。
 这可能导致SecurityException。
 <p>
 When the socket is created the
 <CODE>DatagramSocket#setReuseAddress(true)</CODE> method is
 called to enable the SO_REUSEADDR socket option.
 在创建套接字时,会调用DatagramSocket#setReuseAddress(true)方法来设置SO_REUSEADDR套接字选项。
<P>

<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while creating the MulticastSocket 如果在创建MulticastSocket时发生I/O异常则抛出
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
             <code>checkListen</code> method doesn't allow the operation. 如果存在安全管理器,它的checkListen方法不允许此操作时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkListen(int)"><CODE>SecurityManager.checkListen(int)</CODE></A>,
<A HREF="../../java/net/DatagramSocket.html#setReuseAddress(boolean)"><CODE>DatagramSocket.setReuseAddress(boolean)</CODE></A></DL>
<HR>

<A NAME="MulticastSocket(int)"><!-- --></A><H3>
MulticastSocket</H3>
<PRE>
public <B>MulticastSocket</B>(int&nbsp;port)
                throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Create a multicast socket and bind it to a specific port.
 创建一个绑定在指定端口的多播套接字。
 <p>If there is a security manager,
 its <code>checkListen</code> method is first called
 with the <code>port</code> argument
 as its argument to ensure the operation is allowed.
 This could result in a SecurityException.
 如果存在安全管理器,首先用port作为参数调用checkListen方法来确认操作是否允许。
 这可能导致SecurityException。
 <p>
 When the socket is created the
 <CODE>DatagramSocket#setReuseAddress(true)</CODE> method is
 called to enable the SO_REUSEADDR socket option.
 在创建套接字时,会调用DatagramSocket#setReuseAddress(true)方法来设置SO_REUSEADDR套接字选项。
<P>
<DT><B>Parameters:</B><DD><CODE>port</CODE> - port to use
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while creating the MulticastSocket 如果在创建MulticastSocket时发生I/O异常则抛出
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
             <code>checkListen</code> method doesn't allow the operation. 如果存在安全管理器,它的checkListen方法不允许此操作时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkListen(int)"><CODE>SecurityManager.checkListen(int)</CODE></A>,
<A HREF="../../java/net/DatagramSocket.html#setReuseAddress(boolean)"><CODE>DatagramSocket.setReuseAddress(boolean)</CODE></A></DL>
<HR>

<A NAME="MulticastSocket(java.net.SocketAddress)"><!-- --></A><H3>
MulticastSocket</H3>
<PRE>
public <B>MulticastSocket</B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;bindaddr)
                throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Create a MulticastSocket bound to the specified socket address.
创建一个绑定在指定套接字地址的多播套接字。
 <p>
 Or, if the address is <code>null</code>, create an unbound socket.
 如果地址为null,创建一个未绑定套接字。
 <p>
 <p>If there is a security manager,
 its <code>checkListen</code> method is first called
 with the SocketAddress port as its argument to ensure the operation is allowed.
 This could result in a SecurityException.
 如果存在安全管理器,首先用SocketAddress端口作为参数调用checkListen方法来确认操作是否允许。
 这可能导致SecurityException。
 <p>
 When the socket is created the
 <CODE>DatagramSocket#setReuseAddress(true)</CODE> method is
 called to enable the SO_REUSEADDR socket option.
 在创建套接字时,会调用DatagramSocket#setReuseAddress(true)方法来设置SO_REUSEADDR套接字选项。
<P>
<DT><B>Parameters:</B><DD><CODE>bindaddr</CODE> - Socket address to bind to, or <code>null</code> for
                 an unbound socket. 要绑定的套接字地址,null表示未绑定套接字。
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while creating the MulticastSocket 如果在创建MulticastSocket时发生I/O异常则抛出
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
             <code>checkListen</code> method doesn't allow the operation.
             如果存在安全管理器,它的checkListen方法不允许此操作时抛出。
<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkListen(int)"><CODE>SecurityManager.checkListen(int)</CODE></A>,
<A HREF="../../java/net/DatagramSocket.html#setReuseAddress(boolean)"><CODE>DatagramSocket.setReuseAddress(boolean)</CODE></A></DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="setTTL(byte)"><!-- --></A><H3>
setTTL</H3>
<PRE>
public void <B>setTTL</B>(byte&nbsp;ttl)
            throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>use the setTimeToLive method instead, which uses
 <b>int</b> instead of <b>byte</b> as the type for ttl.
 代之以setTimeToLive方法,其返回int而不是byte。</I>
<P>
<DD>Set the default time-to-live for multicast packets sent out
 on this <code>MulticastSocket</code> in order to control the
 scope of the multicasts.
设置在此多播套接字发出的多播包的默认存活时间以便控制多播的作用域。
 <p>The ttl is an <b>unsigned</b> 8-bit quantity, and so <B>must</B> be
 in the range <code> 0 <= ttl <= 0xFF </code>.
 ttl是一个无符号8位数字,因此必定在0 <= ttl <= 0xFF范围内。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>ttl</CODE> - the time-to-live 存活时间
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while setting the default time-to-live value 当设置默认的存活时间时发生I/O异常时抛出<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#getTTL()"><CODE>getTTL()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setTimeToLive(int)"><!-- --></A><H3>
setTimeToLive</H3>
<PRE>
public void <B>setTimeToLive</B>(int&nbsp;ttl)
                   throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Set the default time-to-live for multicast packets sent out
 on this <code>MulticastSocket</code> in order to control the
 scope of the multicasts.
设置在此多播套接字发出的多播包的默认存活时间以便控制多播的作用域。
 <P> The ttl <B>must</B> be in the range <code> 0 <= ttl <=
 255</code> or an IllegalArgumentException will be thrown.
 ttl必定在0 <= ttl <=255范围内,或者抛出IllegalArgumentException。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>ttl</CODE> - the time-to-live 存活时间
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while setting the default time-to-live value 当设置默认的存活时间时发生I/O异常时抛出<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#getTimeToLive()"><CODE>getTimeToLive()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getTTL()"><!-- --></A><H3>
getTTL</H3>
<PRE>
public byte <B>getTTL</B>()
            throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>use the getTimeToLive method instead, which returns
 an <b>int</b> instead of a <b>byte</b>.
 代之以getTimeToLive方法,其返回int而不是byte。</I>
<P>
<DD>Get the default time-to-live for multicast packets sent out on
 the socket. 获得在套接字上发送的多播包的默认存活时间。
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the default time-to-live value 默认的存活时间
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs
 while getting the default time-to-live value 当设置默认的存活时间时发生I/O异常时抛出<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#setTTL(byte)"><CODE>setTTL(byte)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getTimeToLive()"><!-- --></A><H3>
getTimeToLive</H3>
<PRE>
public int <B>getTimeToLive</B>()
                  throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Get the default time-to-live for multicast packets sent out on
 the socket.
 获得在套接字上发送的多播包的默认存活时间。
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the default time-to-live value 默认的存活时间
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if an I/O exception occurs while
 getting the default time-to-live value 当设置默认的存活时间时发生I/O异常时抛出<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#setTimeToLive(int)"><CODE>setTimeToLive(int)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="joinGroup(java.net.InetAddress)"><!-- --></A><H3>
joinGroup</H3>
<PRE>
public void <B>joinGroup</B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;mcastaddr)
               throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Joins a multicast group. Its behavior may be affected by
 <code>setInterface</code> or <code>setNetworkInterface</code>.
 加入一个多播组。其工作情况可能受setInterface和setNetworkInterface的影响。
 <p>If there is a security manager, this method first
 calls its <code>checkMulticast</code> method
 with the <code>mcastaddr</code> argument
 as its argument.
 如果存在安全管理器,该方法首先以mcastaddr作为参数调用checkMulticast方法。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mcastaddr</CODE> - is the multicast address to join 要加入的多播地址
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if there is an error joining
 or when the address is not a multicast address. 如果加入时有错误或者地址不是一个多播地址时抛出。
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
 <code>checkMulticast</code> method doesn't allow the join.
 如果存在安全管理器,它的checkMulticast方法不允许加入时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkMulticast(java.net.InetAddress)"><CODE>SecurityManager.checkMulticast(InetAddress)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="leaveGroup(java.net.InetAddress)"><!-- --></A><H3>
leaveGroup</H3>
<PRE>
public void <B>leaveGroup</B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;mcastaddr)
                throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Leave a multicast group. Its behavior may be affected by
 <code>setInterface</code> or <code>setNetworkInterface</code>.
 离开一个多播组。其工作情况可能受setInterface和setNetworkInterface的影响。
 <p>If there is a security manager, this method first
 calls its <code>checkMulticast</code> method
 with the <code>mcastaddr</code> argument
 as its argument.
 如果存在安全管理器,该方法首先以mcastaddr作为参数调用checkMulticast方法。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mcastaddr</CODE> - is the multicast address to leave 要离开的多播地址
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if there is an error leaving
 or when the address is not a multicast address. 如果离开时有错误或者地址不是一个多播地址时抛出。
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
 <code>checkMulticast</code> method doesn't allow the operation.
 如果存在安全管理器,它的checkMulticast方法不允许此操作时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkMulticast(java.net.InetAddress)"><CODE>SecurityManager.checkMulticast(InetAddress)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="joinGroup(java.net.SocketAddress, java.net.NetworkInterface)"><!-- --></A><H3>
joinGroup</H3>
<PRE>
public void <B>joinGroup</B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;mcastaddr,
                      <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)
               throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Joins the specified multicast group at the specified interface.
用指定接口加入指定的多播组。
 <p>If there is a security manager, this method first
 calls its <code>checkMulticast</code> method
 with the <code>mcastaddr</code> argument
 as its argument.
 如果存在安全管理器,该方法首先以mcastaddr作为参数调用checkMulticast方法。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mcastaddr</CODE> - is the multicast address to join 要加入的多播地址<DD><CODE>netIf</CODE> - specifies the local interface to receive multicast
        datagram packets, or <i>null</i> to defer to the interface set by
      <A HREF="../../java/net/MulticastSocket.html#setInterface(java.net.InetAddress)"><CODE>setInterface(InetAddress)</CODE></A> or
      <A HREF="../../java/net/MulticastSocket.html#setNetworkInterface(java.net.NetworkInterface)"><CODE>setNetworkInterface(NetworkInterface)</CODE></A>
      指定接收数据报包的本地接口,如果为null,将延期至setInterface(InetAddress)或setNetworkInterface(NetworkInterface)中设置接口
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if there is an error joining
 or when the address is not a multicast address. 如果加入时有错误或者地址不是一个多播地址时抛出。
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
 <code>checkMulticast</code> method doesn't allow the join. 如果存在安全管理器,它的checkMulticast方法不允许加入时抛出。
<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</A></CODE> - if mcastaddr is null or is a
          SocketAddress subclass not supported by this socket
          如果mcastaddr是null,或者此套接字不支持SocketAddress子类时抛出<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkMulticast(java.net.InetAddress)"><CODE>SecurityManager.checkMulticast(InetAddress)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="leaveGroup(java.net.SocketAddress, java.net.NetworkInterface)"><!-- --></A><H3>
leaveGroup</H3>
<PRE>
public void <B>leaveGroup</B>(<A HREF="../../java/net/SocketAddress.html" title="class in java.net">SocketAddress</A>&nbsp;mcastaddr,
                       <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)
                throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD>Leave a multicast group on a specified local interface.
 使指定接口离开多播组。
 <p>If there is a security manager, this method first
 calls its <code>checkMulticast</code> method
 with the <code>mcastaddr</code> argument
 as its argument.
 如果存在安全管理器,该方法首先以mcastaddr作为参数调用checkMulticast方法。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>mcastaddr</CODE> - is the multicast address to leave 要离开的多播地址<DD><CODE>netIf</CODE> - specifies the local interface or <i>null</i> to defer
     to the interface set by
     <A HREF="../../java/net/MulticastSocket.html#setInterface(java.net.InetAddress)"><CODE>setInterface(InetAddress)</CODE></A> or
     <A HREF="../../java/net/MulticastSocket.html#setNetworkInterface(java.net.NetworkInterface)"><CODE>setNetworkInterface(NetworkInterface)</CODE></A>
     指定本地接口,如果为null,将延期至setInterface(InetAddress)或setNetworkInterface(NetworkInterface)中设置接口
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - if there is an error leaving
 or when the address is not a multicast address. 如果离开时有错误或者地址不是一个多播地址时抛出。
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
 <code>checkMulticast</code> method doesn't allow the operation.
 如果存在安全管理器,它的checkMulticast方法不允许此操作时抛出。
<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</A></CODE> - if mcastaddr is null or is a
          SocketAddress subclass not supported by this socket
          如果mcastaddr是null,或者此套接字不支持SocketAddress子类时抛出<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/lang/SecurityManager.html#checkMulticast(java.net.InetAddress)"><CODE>SecurityManager.checkMulticast(InetAddress)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setInterface(java.net.InetAddress)"><!-- --></A><H3>
setInterface</H3>
<PRE>
public void <B>setInterface</B>(<A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A>&nbsp;inf)
                  throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Set the multicast network interface used by methods
 whose behavior would be affected by the value of the
 network interface. Useful for multihomed hosts.
 设置方法使用的多播网络接口,其工作情况将受接口值的影响。用于多播主机。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>inf</CODE> - the InetAddress InetAddress
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if there is an error in
 the underlying protocol, such as a TCP error.
 如果底层协议有错误,例如TCP错误时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#getInterface()"><CODE>getInterface()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getInterface()"><!-- --></A><H3>
getInterface</H3>
<PRE>
public <A HREF="../../java/net/InetAddress.html" title="class in java.net">InetAddress</A> <B>getInterface</B>()
                         throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Retrieve the address of the network interface used for
 multicast packets.
 获得多播套接字使用的网络接口地址。
<P>
<DD><DL>

<DT><B>Returns:</B><DD>An <code>InetAddress</code> representing
  the address of the network interface used for
  multicast packets.
  表示用于多播包的网络接口地址的InetAddress。
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if there is an error in
 the underlying protocol, such as a TCP error.
 如果底层协议有错误,例如TCP错误时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#setInterface(java.net.InetAddress)"><CODE>setInterface(java.net.InetAddress)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setNetworkInterface(java.net.NetworkInterface)"><!-- --></A><H3>
setNetworkInterface</H3>
<PRE>
public void <B>setNetworkInterface</B>(<A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A>&nbsp;netIf)
                         throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Specify the network interface for outgoing multicast datagrams
 sent on this socket.
 指定向此套接字上发送多播数据报的网络接口。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>netIf</CODE> - the interface 接口
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if there is an error in
 the underlying protocol, such as a TCP error. 如果底层协议有错误,例如TCP错误时抛出。<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#getNetworkInterface()"><CODE>getNetworkInterface()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getNetworkInterface()"><!-- --></A><H3>
getNetworkInterface</H3>
<PRE>
public <A HREF="../../java/net/NetworkInterface.html" title="class in java.net">NetworkInterface</A> <B>getNetworkInterface</B>()
                                     throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Get the multicast network interface set. 获得多播网络的接口设置。
<P>
<DD><DL>

<DT><B>Returns:</B><DD>the multicast <code>NetworkInterface</code> currently set 多播NetworkInterface的当前设置
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if there is an error in
 the underlying protocol, such as a TCP error.
 如果底层协议有错误,例如TCP错误时抛出。<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#setNetworkInterface(java.net.NetworkInterface)"><CODE>setNetworkInterface(NetworkInterface)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="setLoopbackMode(boolean)"><!-- --></A><H3>
setLoopbackMode</H3>
<PRE>
public void <B>setLoopbackMode</B>(boolean&nbsp;disable)
                     throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Disable/Enable local loopback of multicast datagrams
 The option is used by the platform's networking code as a hint
 for setting whether multicast data will be looped back to
 the local socket.
设置或取消多播数据报的本地回环,平台的网络代码使用此选项作为一个建议是否设置将多播数据回环到本地套接字。
 <p>Because this option is a hint, applications that want to
 verify what loopback mode is set to should call
 <A HREF="../../java/net/MulticastSocket.html#getLoopbackMode()"><CODE>getLoopbackMode()</CODE></A>
 因为该选项是个建议,因此应用程序想要证实回环模式是否被设置应该调用getLoopbackMode()。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>disable</CODE> - <code>true</code> to disable the LoopbackMode true表示取消回环模式
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if an error occurs while setting the value 当设置该值时发生错误则抛出<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#getLoopbackMode()"><CODE>getLoopbackMode()</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="getLoopbackMode()"><!-- --></A><H3>
getLoopbackMode</H3>
<PRE>
public boolean <B>getLoopbackMode</B>()
                        throws <A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></PRE>
<DL>
<DD>Get the setting for local loopback of multicast datagrams.
获得多播数据报的本地回环设置。
<P>
<DD><DL>

<DT><B>Returns:</B><DD>true if the LoopbackMode has been disabled 如果取消回环模式返回true
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/net/SocketException.html" title="class in java.net">SocketException</A></CODE> - if an error occurs while getting the value 如果获取该值时发生错误则抛出<DT><B>Since:</B></DT>
  <DD>1.4</DD>
<DT><B>See Also:</B><DD><A HREF="../../java/net/MulticastSocket.html#setLoopbackMode(boolean)"><CODE>setLoopbackMode(boolean)</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="send(java.net.DatagramPacket, byte)"><!-- --></A><H3>
send</H3>
<PRE>
public void <B>send</B>(<A HREF="../../java/net/DatagramPacket.html" title="class in java.net">DatagramPacket</A>&nbsp;p,
                 byte&nbsp;ttl)
          throws <A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></PRE>
<DL>
<DD><B>Deprecated.</B>&nbsp;<I>Use the following code or its equivalent instead:
使用下列代码或相当代码代替:
 ......
 int ttl = mcastSocket.getTimeToLive();
  mcastSocket.setTimeToLive(newttl);
 mcastSocket.send(p);
 mcastSocket.setTimeToLive(ttl);
 ......</I>
<P>
<DD>Sends a datagram packet to the destination, with a TTL (time-
 to-live) other than the default for the socket.  This method
 need only be used in instances where a particular TTL is desired;
 otherwise it is preferable to set a TTL once on the socket, and
 use that default TTL for all packets.  This method does <B>not
 </B> alter the default TTL for the socket. Its behavior may be
 affected by <code>setInterface</code>.
发送数据报到目的地地址,使用不同于套接字默认值的存活时间。此方法只有在希望使用特殊的
存活时间时才使用;否则套接字一次性设置TTL更可取,所有包都使用默认TTL。该方法不会改变此套接字的默认TTL,工作情况可能受
setInterface影响。
 <p>If there is a security manager, this method first performs some
 security checks. First, if <code>p.getAddress().isMulticastAddress()</code>
 is true, this method calls the
 security manager's <code>checkMulticast</code> method
 with <code>p.getAddress()</code> and <code>ttl</code> as its arguments.
 If the evaluation of that expression is false,
 this method instead calls the security manager's
 <code>checkConnect</code> method with arguments
 <code>p.getAddress().getHostAddress()</code> and
 <code>p.getPort()</code>. Each call to a security manager method
 could result in a SecurityException if the operation is not allowed.
 如果存在安全管理器,该方法首先执行安全检查。首先,如果p.getAddress().isMulticastAddress()
 为true,该方法用p.getAddress()和ttl作为参数调用安全管理器的checkMulticast方法。
 如果表达式返回false,该方法改成用p.getAddress().getHostAddress()和p.getPort()作为参数调用
 安全管理器的checkConnect方法。每一次调用安全管理器的方法而操作不允许都可能导致SecurityException。
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>p</CODE> - is the packet to be sent. The packet should contain
 the destination multicast ip address and the data to be sent.
 One does not need to be the member of the group to send
 packets to a destination multicast address.
 要发送的包,应包括目的多播地址和发送的数据。不必是发送包至目的多播地址的组的成员。<DD><CODE>ttl</CODE> - optional time to live for multicast packet.
 default ttl is 1. 选择的多播包存活时间,默认ttl为1。
<DT><B>Throws:</B>
<DD><CODE><A HREF="../../java/io/IOException.html" title="class in java.io">IOException</A></CODE> - is raised if an error occurs i.e
 error while setting ttl. 当设置ttl时发生错误则抛出。
<DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if a security manager exists and its 
             <code>checkMulticast</code> or <code>checkConnect</code>
             method doesn't allow the send.
             如果存在安全管理器,它的checkMulticast或者checkConnect方法不允许发送时抛出。<DT><B>See Also:</B><DD><A HREF="../../java/net/DatagramSocket.html#send(java.net.DatagramPacket)"><CODE>DatagramSocket.send(java.net.DatagramPacket)</CODE></A>,
<A HREF="../../java/net/DatagramSocket.html#receive(java.net.DatagramPacket)"><CODE>DatagramSocket.receive(java.net.DatagramPacket)</CODE></A>,
<A HREF="../../java/lang/SecurityManager.html#checkMulticast(java.net.InetAddress, byte)"><CODE>SecurityManager.checkMulticast(java.net.InetAddress, byte)</CODE></A>,
<A HREF="../../java/lang/SecurityManager.html#checkConnect(java.lang.String, int)"><CODE>SecurityManager.checkConnect(java.lang.String, int)</CODE></A></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MulticastSocket.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.4.2</b></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../java/net/JarURLConnection.html" title="class in java.net"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../java/net/NetPermission.html" title="class in java.net"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MulticastSocket.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>

</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
<font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="../../../relnotes/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to <a href="../../../relnotes/license.html">license terms</a>. Also see the <a href="http://java.sun.com/docs/redist.html">documentation redistribution policy</a>.</font>
</BODY>
</HTML>

本文地址:http://com.8s8s.com/it/it9777.htm