src/java.base/share/classes/java/net/SocketImpl.java
changeset 58242 94bb65cb37d3
parent 55346 730ed3fc6605
child 58679 9c3209ff7550
equal deleted inserted replaced
58241:33de7752835c 58242:94bb65cb37d3
   112     /**
   112     /**
   113      * Creates either a stream or a datagram socket.
   113      * Creates either a stream or a datagram socket.
   114      *
   114      *
   115      * @param      stream   if {@code true}, create a stream socket;
   115      * @param      stream   if {@code true}, create a stream socket;
   116      *                      otherwise, create a datagram socket.
   116      *                      otherwise, create a datagram socket.
   117      * @exception  IOException  if an I/O error occurs while creating the
   117      * @throws     IOException  if an I/O error occurs while creating the
   118      *               socket.
   118      *               socket.
   119      */
   119      */
   120     protected abstract void create(boolean stream) throws IOException;
   120     protected abstract void create(boolean stream) throws IOException;
   121 
   121 
   122     /**
   122     /**
   123      * Connects this socket to the specified port on the named host.
   123      * Connects this socket to the specified port on the named host.
   124      *
   124      *
   125      * @param      host   the name of the remote host.
   125      * @param      host   the name of the remote host.
   126      * @param      port   the port number.
   126      * @param      port   the port number.
   127      * @exception  IOException  if an I/O error occurs when connecting to the
   127      * @throws     IOException  if an I/O error occurs when connecting to the
   128      *               remote host.
   128      *               remote host.
   129      */
   129      */
   130     protected abstract void connect(String host, int port) throws IOException;
   130     protected abstract void connect(String host, int port) throws IOException;
   131 
   131 
   132     /**
   132     /**
   133      * Connects this socket to the specified port number on the specified host.
   133      * Connects this socket to the specified port number on the specified host.
   134      *
   134      *
   135      * @param      address   the IP address of the remote host.
   135      * @param      address   the IP address of the remote host.
   136      * @param      port      the port number.
   136      * @param      port      the port number.
   137      * @exception  IOException  if an I/O error occurs when attempting a
   137      * @throws     IOException  if an I/O error occurs when attempting a
   138      *               connection.
   138      *               connection.
   139      */
   139      */
   140     protected abstract void connect(InetAddress address, int port) throws IOException;
   140     protected abstract void connect(InetAddress address, int port) throws IOException;
   141 
   141 
   142     /**
   142     /**
   144      * A timeout of zero is interpreted as an infinite timeout. The connection
   144      * A timeout of zero is interpreted as an infinite timeout. The connection
   145      * will then block until established or an error occurs.
   145      * will then block until established or an error occurs.
   146      *
   146      *
   147      * @param      address   the Socket address of the remote host.
   147      * @param      address   the Socket address of the remote host.
   148      * @param     timeout  the timeout value, in milliseconds, or zero for no timeout.
   148      * @param     timeout  the timeout value, in milliseconds, or zero for no timeout.
   149      * @exception  IOException  if an I/O error occurs when attempting a
   149      * @throws     IOException  if an I/O error occurs when attempting a
   150      *               connection.
   150      *               connection.
   151      * @since 1.4
   151      * @since 1.4
   152      */
   152      */
   153     protected abstract void connect(SocketAddress address, int timeout) throws IOException;
   153     protected abstract void connect(SocketAddress address, int timeout) throws IOException;
   154 
   154 
   155     /**
   155     /**
   156      * Binds this socket to the specified local IP address and port number.
   156      * Binds this socket to the specified local IP address and port number.
   157      *
   157      *
   158      * @param      host   an IP address that belongs to a local interface.
   158      * @param      host   an IP address that belongs to a local interface.
   159      * @param      port   the port number.
   159      * @param      port   the port number.
   160      * @exception  IOException  if an I/O error occurs when binding this socket.
   160      * @throws     IOException  if an I/O error occurs when binding this socket.
   161      */
   161      */
   162     protected abstract void bind(InetAddress host, int port) throws IOException;
   162     protected abstract void bind(InetAddress host, int port) throws IOException;
   163 
   163 
   164     /**
   164     /**
   165      * Sets the maximum queue length for incoming connection indications
   165      * Sets the maximum queue length for incoming connection indications
   166      * (a request to connect) to the {@code count} argument. If a
   166      * (a request to connect) to the {@code count} argument. If a
   167      * connection indication arrives when the queue is full, the
   167      * connection indication arrives when the queue is full, the
   168      * connection is refused.
   168      * connection is refused.
   169      *
   169      *
   170      * @param      backlog   the maximum length of the queue.
   170      * @param      backlog   the maximum length of the queue.
   171      * @exception  IOException  if an I/O error occurs when creating the queue.
   171      * @throws     IOException  if an I/O error occurs when creating the queue.
   172      */
   172      */
   173     protected abstract void listen(int backlog) throws IOException;
   173     protected abstract void listen(int backlog) throws IOException;
   174 
   174 
   175     /**
   175     /**
   176      * Accepts a connection.
   176      * Accepts a connection.
   177      *
   177      *
   178      * @param      s   the accepted connection.
   178      * @param      s   the accepted connection.
   179      * @exception  IOException  if an I/O error occurs when accepting the
   179      * @throws     IOException  if an I/O error occurs when accepting the
   180      *               connection.
   180      *               connection.
   181      */
   181      */
   182     protected abstract void accept(SocketImpl s) throws IOException;
   182     protected abstract void accept(SocketImpl s) throws IOException;
   183 
   183 
   184     /**
   184     /**
   185      * Returns an input stream for this socket.
   185      * Returns an input stream for this socket.
   186      *
   186      *
   187      * @return     a stream for reading from this socket.
   187      * @return     a stream for reading from this socket.
   188      * @exception  IOException  if an I/O error occurs when creating the
   188      * @throws     IOException  if an I/O error occurs when creating the
   189      *               input stream.
   189      *               input stream.
   190     */
   190     */
   191     protected abstract InputStream getInputStream() throws IOException;
   191     protected abstract InputStream getInputStream() throws IOException;
   192 
   192 
   193     /**
   193     /**
   194      * Returns an output stream for this socket.
   194      * Returns an output stream for this socket.
   195      *
   195      *
   196      * @return     an output stream for writing to this socket.
   196      * @return     an output stream for writing to this socket.
   197      * @exception  IOException  if an I/O error occurs when creating the
   197      * @throws     IOException  if an I/O error occurs when creating the
   198      *               output stream.
   198      *               output stream.
   199      */
   199      */
   200     protected abstract OutputStream getOutputStream() throws IOException;
   200     protected abstract OutputStream getOutputStream() throws IOException;
   201 
   201 
   202     /**
   202     /**
   203      * Returns the number of bytes that can be read from this socket
   203      * Returns the number of bytes that can be read from this socket
   204      * without blocking.
   204      * without blocking.
   205      *
   205      *
   206      * @return     the number of bytes that can be read from this socket
   206      * @return     the number of bytes that can be read from this socket
   207      *             without blocking.
   207      *             without blocking.
   208      * @exception  IOException  if an I/O error occurs when determining the
   208      * @throws     IOException  if an I/O error occurs when determining the
   209      *               number of bytes available.
   209      *               number of bytes available.
   210      */
   210      */
   211     protected abstract int available() throws IOException;
   211     protected abstract int available() throws IOException;
   212 
   212 
   213     /**
   213     /**
   214      * Closes this socket.
   214      * Closes this socket.
   215      *
   215      *
   216      * @exception  IOException  if an I/O error occurs when closing this socket.
   216      * @throws     IOException  if an I/O error occurs when closing this socket.
   217      */
   217      */
   218     protected abstract void close() throws IOException;
   218     protected abstract void close() throws IOException;
   219 
   219 
   220     /**
   220     /**
   221      * Closes this socket, ignoring any IOException that is thrown by close.
   221      * Closes this socket, ignoring any IOException that is thrown by close.
   233      *
   233      *
   234      * If you read from a socket input stream after invoking this method on the
   234      * If you read from a socket input stream after invoking this method on the
   235      * socket, the stream's {@code available} method will return 0, and its
   235      * socket, the stream's {@code available} method will return 0, and its
   236      * {@code read} methods will return {@code -1} (end of stream).
   236      * {@code read} methods will return {@code -1} (end of stream).
   237      *
   237      *
   238      * @exception IOException if an I/O error occurs when shutting down this
   238      * @throws    IOException if an I/O error occurs when shutting down this
   239      * socket.
   239      * socket.
   240      * @see java.net.Socket#shutdownOutput()
   240      * @see java.net.Socket#shutdownOutput()
   241      * @see java.net.Socket#close()
   241      * @see java.net.Socket#close()
   242      * @see java.net.Socket#setSoLinger(boolean, int)
   242      * @see java.net.Socket#setSoLinger(boolean, int)
   243      * @since 1.3
   243      * @since 1.3
   253      *
   253      *
   254      * If you write to a socket output stream after invoking
   254      * If you write to a socket output stream after invoking
   255      * shutdownOutput() on the socket, the stream will throw
   255      * shutdownOutput() on the socket, the stream will throw
   256      * an IOException.
   256      * an IOException.
   257      *
   257      *
   258      * @exception IOException if an I/O error occurs when shutting down this
   258      * @throws    IOException if an I/O error occurs when shutting down this
   259      * socket.
   259      * socket.
   260      * @see java.net.Socket#shutdownInput()
   260      * @see java.net.Socket#shutdownInput()
   261      * @see java.net.Socket#close()
   261      * @see java.net.Socket#close()
   262      * @see java.net.Socket#setSoLinger(boolean, int)
   262      * @see java.net.Socket#setSoLinger(boolean, int)
   263      * @since 1.3
   263      * @since 1.3
   311 
   311 
   312     /**
   312     /**
   313      * Send one byte of urgent data on the socket.
   313      * Send one byte of urgent data on the socket.
   314      * The byte to be sent is the low eight bits of the parameter
   314      * The byte to be sent is the low eight bits of the parameter
   315      * @param data The byte of data to send
   315      * @param data The byte of data to send
   316      * @exception IOException if there is an error
   316      * @throws    IOException if there is an error
   317      *  sending the data.
   317      *  sending the data.
   318      * @since 1.4
   318      * @since 1.4
   319      */
   319      */
   320     protected abstract void sendUrgentData (int data) throws IOException;
   320     protected abstract void sendUrgentData (int data) throws IOException;
   321 
   321