src/java.base/share/classes/java/net/SocketImpl.java
branchniosocketimpl-branch
changeset 57260 bb5198288772
parent 57239 7636aef1b197
child 57268 adcdd45830a0
equal deleted inserted replaced
57252:d70fc9bc1430 57260:bb5198288772
     1 /*
     1 /*
     2  * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   202      * @exception  IOException  if an I/O error occurs when closing this socket.
   202      * @exception  IOException  if an I/O error occurs when closing this socket.
   203      */
   203      */
   204     protected abstract void close() throws IOException;
   204     protected abstract void close() throws IOException;
   205 
   205 
   206     /**
   206     /**
       
   207      * Closes this socket, ignoring any IOException that is thrown by close.
       
   208      */
       
   209     void closeQuietly() {
       
   210         try {
       
   211             close();
       
   212         } catch (IOException ignore) { }
       
   213     }
       
   214 
       
   215     /**
   207      * Places the input stream for this socket at "end of stream".
   216      * Places the input stream for this socket at "end of stream".
   208      * Any data sent to this socket is acknowledged and then
   217      * Any data sent to this socket is acknowledged and then
   209      * silently discarded.
   218      * silently discarded.
   210      *
   219      *
   211      * If you read from a socket input stream after invoking this method on the
   220      * If you read from a socket input stream after invoking this method on the
   468         } else {
   477         } else {
   469             throw new UnsupportedOperationException("unsupported option");
   478             throw new UnsupportedOperationException("unsupported option");
   470         }
   479         }
   471     }
   480     }
   472 
   481 
       
   482     /**
       
   483      * Attempts to copy socket options from this SocketImpl to a target SocketImpl.
       
   484      * At this time, only the SO_TIMEOUT make sense to copy.
       
   485      */
       
   486     void copyOptionsTo(SocketImpl target) {
       
   487         try {
       
   488             Object timeout = getOption(SocketOptions.SO_TIMEOUT);
       
   489             if (timeout instanceof Integer) {
       
   490                 target.setOption(SocketOptions.SO_TIMEOUT, timeout);
       
   491             }
       
   492         } catch (IOException ignore) { }
       
   493     }
       
   494 
   473     private static final Set<SocketOption<?>> socketOptions;
   495     private static final Set<SocketOption<?>> socketOptions;
   474 
   496 
   475     private static final Set<SocketOption<?>> serverSocketOptions;
   497     private static final Set<SocketOption<?>> serverSocketOptions;
   476 
   498 
   477     static {
   499     static {