📄 socket.html
字号:
throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Returns 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/Socket.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 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>Socket</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 <tt>Socket</tt>. <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/Socket.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><A HREF="../../java/net/SocketException.html">SocketException</A></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/Socket.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>Socket</tt>, that is the buffer size used by the platform for output on this <tt>Socket</tt>.<DD><DL><DT><B>Returns:</B><DD>the value of the SO_SNDBUF option for this <tt>Socket</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/Socket.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 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>Socket</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>Socket</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/Socket.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><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the value is 0 or is negative.<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/Socket.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>Gets the value of the SO_RCVBUF option for this <tt>Socket</tt>, that is the buffer size used by the platform for input on this <tt>Socket</tt>.<DD><DL><DT><B>Returns:</B><DD>the value of the SO_RCVBUF option for this <tt>Socket</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/Socket.html#setReceiveBufferSize(int)"><CODE>setReceiveBufferSize(int)</CODE></A></DL></DD></DL><HR><A NAME="setKeepAlive(boolean)"><!-- --></A><H3>setKeepAlive</H3><PRE>public void <B>setKeepAlive</B>(boolean on) throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Enable/disable SO_KEEPALIVE.<DD><DL><DT><B>Parameters:</B><DD><CODE>on</CODE> - whether or not to have socket keep alive turned on.<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>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../java/net/Socket.html#getKeepAlive()"><CODE>getKeepAlive()</CODE></A></DL></DD></DL><HR><A NAME="getKeepAlive()"><!-- --></A><H3>getKeepAlive</H3><PRE>public boolean <B>getKeepAlive</B>() throws <A HREF="../../java/net/SocketException.html">SocketException</A></PRE><DL><DD>Tests if SO_KEEPALIVE is enabled.<DD><DL><DT><B>Returns:</B><DD>a <code>boolean</code> indicating whether or not SO_KEEPALIVE is enabled.<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>1.3</DD><DT><B>See Also: </B><DD><A HREF="../../java/net/Socket.html#setKeepAlive(boolean)"><CODE>setKeepAlive(boolean)</CODE></A></DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>public void <B>close</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Closes this socket.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs when closing this socket.</DL></DD></DL><HR><A NAME="shutdownInput()"><!-- --></A><H3>shutdownInput</H3><PRE>public void <B>shutdownInput</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Places the input stream for this socket at "end of stream". Any data sent to the input stream side of the socket is acknowledged and then silently discarded. If you read from a socket input stream after invoking shutdownInput() on the socket, the stream will return EOF.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs when shutting down this socket.<DT><B>See Also: </B><DD><A HREF="../../java/net/Socket.html#shutdownOutput()"><CODE>shutdownOutput()</CODE></A>, <A HREF="../../java/net/Socket.html#close()"><CODE>close()</CODE></A>, <A HREF="../../java/net/Socket.html#setSoLinger(boolean, int)"><CODE>setSoLinger(boolean, int)</CODE></A></DL></DD></DL><HR><A NAME="shutdownOutput()"><!-- --></A><H3>shutdownOutput</H3><PRE>public void <B>shutdownOutput</B>() throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Disables the output stream for this socket. For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence. If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs when shutting down this socket.<DT><B>See Also: </B><DD><A HREF="../../java/net/Socket.html#shutdownInput()"><CODE>shutdownInput()</CODE></A>, <A HREF="../../java/net/Socket.html#close()"><CODE>close()</CODE></A>, <A HREF="../../java/net/Socket.html#setSoLinger(boolean, int)"><CODE>setSoLinger(boolean, int)</CODE></A></DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Converts this socket to a <code>String</code>.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>a string representation of this socket.</DL></DD></DL><HR><A NAME="setSocketImplFactory(java.net.SocketImplFactory)"><!-- --></A><H3>setSocketImplFactory</H3><PRE>public static void <B>setSocketImplFactory</B>(<A HREF="../../java/net/SocketImplFactory.html">SocketImplFactory</A> fac) throws <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>Sets the client socket implementation factory for the application. The factory can be specified only once. <p> When an application creates a new client socket, the socket implementation factory's <code>createSocketImpl</code> method is called to create the actual 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 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/SocketImplFactory.html#createSocketImpl()"><CODE>SocketImplFactory.createSocketImpl()</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> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Socket.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/net/ServerSocket.html"><B>PREV CLASS</B></A> <A HREF="../../java/net/SocketImpl.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> <A HREF="Socket.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <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 + -