⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datagramsocket.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 3 页
字号:
 <p> If there is a security manager, a packet cannot be received if the security manager's <code>checkAccept</code> method does not allow it.<DD><DL><DT><B>Parameters:</B><DD><CODE>p</CODE> - the <code>DatagramPacket</code> into which to place                 the incoming data.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramPacket.html"><CODE>DatagramPacket</CODE></A>, <A HREF="../../java/net/DatagramSocket.html"><CODE>DatagramSocket</CODE></A></DL></DD></DL><HR><A NAME="getLocalAddress()"><!-- --></A><H3>getLocalAddress</H3><PRE>public <A HREF="../../java/net/InetAddress.html">InetAddress</A> <B>getLocalAddress</B>()</PRE><DL><DD>Gets the local address to which the socket is bound. <p>If there is a security manager, its <code>checkConnect</code> method is first called with the host address and <code>-1</code>  as its arguments to see if the operation is allowed.<DD><DL><DT><B>Returns:</B><DD>an <tt>InetAddress</tt> representing the local address to which the socket is bound<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if a security manager exists and its    <code>checkConnect</code> method doesn't allow the operation.<DT><B>Since: </B><DD>1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkConnect(java.lang.String, int)"><CODE>SecurityManager.checkConnect(java.lang.String, int)</CODE></A></DL></DD></DL><HR><A NAME="getLocalPort()"><!-- --></A><H3>getLocalPort</H3><PRE>public int <B>getLocalPort</B>()</PRE><DL><DD>Returns the port number on the local host to which this socket is bound.<DD><DL><DT><B>Returns:</B><DD>the port number on the local host to which this socket is bound.</DL></DD></DL><HR><A NAME="setSoTimeout(int)"><!-- --></A><H3>setSoTimeout</H3><PRE>public void <B>setSoTimeout</B>(int&nbsp;timeout)                  throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Enable/disable SO_TIMEOUT with the specified timeout, in  milliseconds. With this option set to a non-zero timeout,  a call to receive() for this DatagramSocket  will block for only this amount of time.  If the timeout expires,  a <B>java.io.InterruptedIOException</B> is raised, though the  ServerSocket is still valid.  The option <B>must</B> be enabled  prior to entering the blocking operation to have effect.  The  timeout must be > 0.  A timeout of zero is interpreted as an infinite timeout.<DD><DL><DT><B>Parameters:</B><DD><CODE>timeout</CODE> - the specified timeout in milliseconds.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/SocketException.html">SocketException</A></CODE> - if there is an error in the underlying protocol, such as a TCP error.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#getSoTimeout()"><CODE>getSoTimeout()</CODE></A></DL></DD></DL><HR><A NAME="getSoTimeout()"><!-- --></A><H3>getSoTimeout</H3><PRE>public int <B>getSoTimeout</B>()                 throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Retrive setting for SO_TIMEOUT.  0 returns implies that the option is disabled (i.e., timeout of infinity).<DD><DL><DT><B>Returns:</B><DD>the setting for SO_TIMEOUT<DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/SocketException.html">SocketException</A></CODE> - if there is an error in the underlying protocol, such as a TCP error.<DT><B>Since: </B><DD>JDK1.1</DD><DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#setSoTimeout(int)"><CODE>setSoTimeout(int)</CODE></A></DL></DD></DL><HR><A NAME="setSendBufferSize(int)"><!-- --></A><H3>setSendBufferSize</H3><PRE>public void <B>setSendBufferSize</B>(int&nbsp;size)                       throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Sets the SO_SNDBUF option to the specified value for this <tt>DatagramSocket</tt>. The SO_SNDBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers. <p>Increasing buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. For UDP, this sets the maximum size of a packet that may be sent on this socket. <p>Because SO_SNDBUF is a hint, applications that want to verify what size the buffers were set to should call <A HREF="../../java/net/DatagramSocket.html#getSendBufferSize()"><CODE>getSendBufferSize()</CODE></A>.<DD><DL><DT><B>Parameters:</B><DD><CODE>size</CODE> - the size to which to set the send buffer size. This value must be greater than 0.<DT><B>Throws:</B><DD><CODE><tt>SocketException</tt></CODE> - if there is an error  in the underlying protocol, such as a TCP error.<DD><CODE><tt>IllegalArgumentException</tt></CODE> - if the value is 0 or is negative.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#getSendBufferSize()"><CODE>getSendBufferSize()</CODE></A></DL></DD></DL><HR><A NAME="getSendBufferSize()"><!-- --></A><H3>getSendBufferSize</H3><PRE>public int <B>getSendBufferSize</B>()                      throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Get value of the SO_SNDBUF option for this <tt>DatagramSocket</tt>, that is the buffer size used by the platform for output on this <tt>DatagramSocket</tt>.<DD><DL><DT><B>Returns:</B><DD>the value of the SO_SNDBUF option for this <tt>DatagramSocket</tt><DT><B>Throws:</B><DD><CODE><tt>SocketException</tt></CODE> - if there is an error in  the underlying protocol, such as a TCP error.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#setSendBufferSize(int)"><CODE>setSendBufferSize(int)</CODE></A></DL></DD></DL><HR><A NAME="setReceiveBufferSize(int)"><!-- --></A><H3>setReceiveBufferSize</H3><PRE>public void <B>setReceiveBufferSize</B>(int&nbsp;size)                          throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Sets the SO_RCVBUF option to the specified value for this <tt>DatagramSocket</tt>. The SO_RCVBUF option is used by the platform's networking code as a hint for the size to set the underlying network I/O buffers. <p>Increasing buffer size can increase the performance of network I/O for high-volume connection, while decreasing it can help reduce the backlog of incoming data. For UDP, this sets the maximum size of a packet that may be sent on this <tt>DatagramSocket</tt>. <p>Because SO_RCVBUF is a hint, applications that want to verify what size the buffers were set to should call <A HREF="../../java/net/DatagramSocket.html#getReceiveBufferSize()"><CODE>getReceiveBufferSize()</CODE></A>.<DD><DL><DT><B>Parameters:</B><DD><CODE>size</CODE> - the size to which to set the receive buffer size. This value must be greater than 0.<DT><B>Throws:</B><DD><CODE><tt>SocketException</tt></CODE> - if there is an error in  the underlying protocol, such as a TCP error.<DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the value is 0 or is negative.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#getReceiveBufferSize()"><CODE>getReceiveBufferSize()</CODE></A></DL></DD></DL><HR><A NAME="getReceiveBufferSize()"><!-- --></A><H3>getReceiveBufferSize</H3><PRE>public int <B>getReceiveBufferSize</B>()                         throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Get value of the SO_RCVBUF option for this <tt>DatagramSocket</tt>, that is the buffer size used by the platform for input on this <tt>DatagramSocket</tt>.<DD><DL><DT><B>Returns:</B><DD>the value of the SO_RCVBUF option for this <tt>DatagramSocket</tt><DT><B>Throws:</B><DD><CODE><A HREF="../../java/net/SocketException.html">SocketException</A></CODE> - if there is an error in the underlying protocol, such as a TCP error.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocket.html#setReceiveBufferSize(int)"><CODE>setReceiveBufferSize(int)</CODE></A></DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>public void <B>close</B>()</PRE><DL><DD>Closes this datagram socket.</DL><HR><A NAME="setDatagramSocketImplFactory(java.net.DatagramSocketImplFactory)"><!-- --></A><H3>setDatagramSocketImplFactory</H3><PRE>public static void <B>setDatagramSocketImplFactory</B>(<A HREF="../../java/net/DatagramSocketImplFactory.html">DatagramSocketImplFactory</A>&nbsp;fac)                                         throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Sets the datagram socket implementation factory for the application. The factory can be specified only once. <p> When an application creates a new datagram socket, the socket implementation factory's <code>createDatagramSocketImpl</code> method is called to create the actual datagram socket implementation.  <p>If there is a security manager, this method first calls the security manager's <code>checkSetFactory</code> method  to ensure the operation is allowed.  This could result in a SecurityException.<DD><DL><DT><B>Parameters:</B><DD><CODE>fac</CODE> - the desired factory.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs when setting the              datagram socket factory.<DD><CODE><A HREF="../../java/net/SocketException.html">SocketException</A></CODE> - if the factory is already defined.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if a security manager exists and its               <code>checkSetFactory</code> method doesn't allow the operation.<DT><B>See Also: </B><DD><A HREF="../../java/net/DatagramSocketImplFactory.html#createDatagramSocketImpl()"><CODE>DatagramSocketImplFactory.createDatagramSocketImpl()</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkSetFactory()"><CODE>SecurityManager.checkSetFactory()</CODE></A></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <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/DatagramSocket.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.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../java/net/DatagramPacket.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../java/net/DatagramSocketImpl.html"><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="DatagramSocket.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;INNER&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><!-- =========== END OF 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="http://java.sun.com/products/jdk/1.3/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>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A.  All Rights Reserved.</font></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -