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

📄 socketconnection.html

📁 J2ME MIDP2.0 final specification
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Fri Sep 27 14:47:30 CDT 2002 --><TITLE>Mobile Information Device Profile 2.0: Interface  SocketConnection</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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/SocketConnection.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-all.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><strong>MIDP 2.0</strong></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../javax/microedition/io/ServerSocketConnection.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<B>NEXT CLASS</B></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="SocketConnection.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;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.microedition.io</FONT><BR>Interface  SocketConnection</H2><DL><DT><B>All Superinterfaces:</B> <DD>Connection, InputConnection, OutputConnection, StreamConnection</DD></DL><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../../javax/microedition/io/SecureConnection.html">SecureConnection</A></DD></DL><HR><DL><DT>public interface <B>SocketConnection</B><DT>extends StreamConnection</DL><P>This interface defines the socket stream connection. <P> A socket is accessed using a generic connection string with an explicit host and port number. The host may be specified as a fully qualified host name or IPv4 number. e.g. <code>socket://host.com:79</code> defines a target socket on the <code>host.com</code> system at port <code>79</code>. <P>Note that RFC1900 recommends the use of names rather than IP numbers for best results in the event of IP number reassignment. </P> <H3> Closing Streams </H3> <P> Every <code>StreamConnection</code> provides a <code>Connection</code> object as well as an <code>InputStream</code> and <code>OutputStream</code> to handle the I/O associated with the connection. Each of these interfaces has its own <code>close()</code> method. For systems that support duplex communication over the socket connection, closing of the input or output stream SHOULD shutdown just that side of the connection. e.g. closing the <code>InputStream</code> will permit the <code>OutputStream</code> to continue sending data. </P> <P> Once the input or output stream has been closed, it can only be reopened with a call to <code>Connector.open()</code>. The application will receive an <code>IOException</code> if an attempt is made to reopen the stream. </P> <H2> BNF Format for Connector.open() string </H2> <P> The URI must conform to the BNF syntax specified below.  If the URI does not conform to this syntax, an <code>IllegalArgumentException</code> is thrown. </P> <TABLE BORDER="1"> <TR> <TD>&lt;socket_connection_string&gt; </TD> <TD>::= "<strong>socket://</strong>"&lt;hostport&gt; </TD> </TR> <TR> <TD>&lt;hostport&gt; </TD> <TD>::= <I>host</I> ":" <I>port </I> </TD> </TR> <TR> <TD>&lt;host&gt; </TD> <TD>::= <I>host name or IP address </I> (omitted for inbound connections, See <a href="ServerSocketConnection.html">ServerSocketConnection</a>) </TD> </TR> <TR> <TD>&lt;port&gt; </TD> <TD>::= <I>numeric port number </I> </TD> </TR> </TABLE> <H3> Examples </H3> <P> The following examples show how a <code>SocketConnection</code> would be used to access a sample loopback program. </P> <PRE>   SocketConnection sc = (SocketConnection)                         Connector.open("socket://host.com:79");   sc.setSocketOption(SocketConnection.LINGER, 5);   InputStream is  = sc.openInputStream();   OutputStream os = sc.openOutputStream();   os.write("\r\n".getBytes());   int ch = 0;   while(ch != -1) {       ch = is.read();   }   is.close();   os.close();   sc.close(); </PRE><P><DL><DT><B>Since: </B><DD>MIDP 2.0</DD></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#DELAY">DELAY</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket option for the small buffer <em>writing delay</em> (0).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#KEEPALIVE">KEEPALIVE</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket option for the <em>keep alive</em> feature (2).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#LINGER">LINGER</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket option for the <em>linger time</em> to wait in seconds before closing a connection with pending data output (1).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#RCVBUF">RCVBUF</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket option for the size of the <em>receiving buffer</em> (3).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#SNDBUF">SNDBUF</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Socket option for the size of the <em>sending buffer</em> (4).</TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><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;String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#getAddress()">getAddress</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the remote address to which the socket is bound.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;String</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/microedition/io/SocketConnection.html#getLocalAddress()">getLocalAddress</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the local address to which the socket is bound.</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="../../../javax/microedition/io/SocketConnection.html#getLocalPort()">getLocalPort</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the local port to which this socket is bound.</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="../../../javax/microedition/io/SocketConnection.html#getPort()">getPort</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the remote port to which this socket is bound.</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="../../../javax/microedition/io/SocketConnection.html#getSocketOption(byte)">getSocketOption</A></B>(byte&nbsp;option)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get a socket option for the connection.</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="../../../javax/microedition/io/SocketConnection.html#setSocketOption(byte, int)">setSocketOption</A></B>(byte&nbsp;option,                int&nbsp;value)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set a socket option for the connection.</TD></TR>

⌨️ 快捷键说明

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