9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.nio.channels; 27 28 import java.io.IOException; 29 import java.net.ProtocolFamily; 30 import java.net.ServerSocket; 31 import java.net.SocketOption; 32 import java.net.SocketAddress; 33 import java.nio.channels.spi.AbstractSelectableChannel; 34 import java.nio.channels.spi.SelectorProvider; 35 import static java.util.Objects.requireNonNull; 36 37 /** 38 * A selectable channel for stream-oriented listening sockets. 39 * 40 * <p> A server-socket channel is created by invoking the {@link #open() open} 41 * method of this class. It is not possible to create a channel for an arbitrary, 42 * pre-existing {@link ServerSocket}. A newly-created server-socket channel is 43 * open but not yet bound. An attempt to invoke the {@link #accept() accept} 44 * method of an unbound server-socket channel will cause a {@link NotYetBoundException} 45 * to be thrown. A server-socket channel can be bound by invoking one of the 46 * {@link #bind(java.net.SocketAddress,int) bind} methods defined by this class. 47 * 48 * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) 49 * setOption} method. Server-socket channels support the following options: 50 * <blockquote> 51 * <table class="striped"> 52 * <caption style="display:none">Socket options</caption> 53 * <thead> 54 * <tr> 55 * <th scope="col">Option Name</th> 56 * <th scope="col">Description</th> 57 * </tr> 58 * </thead> 59 * <tbody> 60 * <tr> 61 * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th> 62 * <td> The size of the socket receive buffer </td> 63 * </tr> 64 * <tr> 65 * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th> 66 * <td> Re-use address </td> 67 * </tr> 68 * </tbody> 69 * </table> 70 * </blockquote> 71 * Additional (implementation specific) options may also be supported. 72 * 73 * <p> Server-socket channels are safe for use by multiple concurrent threads. 74 * </p> 75 * 76 * @author Mark Reinhold 77 * @author JSR-51 Expert Group 78 * @since 1.4 79 */ 80 81 public abstract class ServerSocketChannel 82 extends AbstractSelectableChannel 83 implements NetworkChannel 84 { 85 86 /** 87 * Initializes a new instance of this class. 88 * 89 * @param provider 90 * The provider that created this channel 91 */ 92 protected ServerSocketChannel(SelectorProvider provider) { 93 super(provider); 94 } 95 96 /** 97 * Opens a server-socket channel. 98 * 99 * <p> The new channel is created by invoking the {@link 100 * java.nio.channels.spi.SelectorProvider#openServerSocketChannel 101 * openServerSocketChannel} method of the system-wide default {@link 102 * java.nio.channels.spi.SelectorProvider} object. 103 * 104 * <p> The new channel's socket is initially unbound; it must be bound to a 105 * specific address via one of its socket's {@link 106 * java.net.ServerSocket#bind(SocketAddress) bind} methods before 107 * connections can be accepted. </p> 108 * 109 * @return A new socket channel 110 * 111 * @throws IOException 112 * If an I/O error occurs 113 */ 114 public static ServerSocketChannel open() throws IOException { 115 return SelectorProvider.provider().openServerSocketChannel(); 116 } 117 118 /** 119 * Opens a server-socket channel.The {@code family} parameter specifies the 120 * {@link ProtocolFamily protocol family} of the channel's socket. 121 * 122 * <p> The new channel is created by invoking the {@link 123 * java.nio.channels.spi.SelectorProvider#openServerSocketChannel(ProtocolFamily) 124 * openServerSocketChannel(ProtocolFamily)} method of the system-wide default {@link 125 * java.nio.channels.spi.SelectorProvider} object. </p> 126 * 127 * @param family 128 * The protocol family 129 * 130 * @return A new socket channel 131 * 132 * @throws UnsupportedOperationException 133 * If the specified protocol family is not supported. For example, 134 * suppose the parameter is specified as {@link 135 * java.net.StandardProtocolFamily#INET6 StandardProtocolFamily.INET6} 136 * but IPv6 is not enabled on the platform. 137 * @throws IOException 138 * If an I/O error occurs 139 * 140 * @since 15 141 */ 142 public static ServerSocketChannel open(ProtocolFamily family) throws IOException { 143 return SelectorProvider.provider().openServerSocketChannel(requireNonNull(family)); 144 } 145 146 /** 147 * Returns an operation set identifying this channel's supported 148 * operations. 149 * 150 * <p> Server-socket channels only support the accepting of new 151 * connections, so this method returns {@link SelectionKey#OP_ACCEPT}. 152 * </p> 153 * 154 * @return The valid-operation set 155 */ 156 public final int validOps() { 157 return SelectionKey.OP_ACCEPT; 158 } 159 163 /** 164 * Binds the channel's socket to a local address and configures the socket 165 * to listen for connections. 166 * 167 * <p> An invocation of this method is equivalent to the following: 168 * <blockquote><pre> 169 * bind(local, 0); 170 * </pre></blockquote> 171 * 172 * @param local 173 * The local address to bind the socket, or {@code null} to bind 174 * to an automatically assigned socket address 175 * 176 * @return This channel 177 * 178 * @throws AlreadyBoundException {@inheritDoc} 179 * @throws UnsupportedAddressTypeException {@inheritDoc} 180 * @throws ClosedChannelException {@inheritDoc} 181 * @throws IOException {@inheritDoc} 182 * @throws SecurityException 183 * If a security manager has been installed and its {@link 184 * SecurityManager#checkListen checkListen} method denies the 185 * operation 186 * 187 * @since 1.7 188 */ 189 public final ServerSocketChannel bind(SocketAddress local) 190 throws IOException 191 { 192 return bind(local, 0); 193 } 194 195 /** 196 * Binds the channel's socket to a local address and configures the socket to 197 * listen for connections. 198 * 199 * <p> This method is used to establish an association between the socket and 200 * a local address. Once an association is established then the socket remains 201 * bound until the channel is closed. 202 * 203 * <p> The {@code backlog} parameter is the maximum number of pending 204 * connections on the socket. Its exact semantics are implementation specific. 205 * In particular, an implementation may impose a maximum length or may choose 206 * to ignore the parameter altogther. If the {@code backlog} parameter has 207 * the value {@code 0}, or a negative value, then an implementation specific 208 * default is used. 209 * 210 * @param local 211 * The address to bind the socket, or {@code null} to bind to an 212 * automatically assigned socket address 213 * @param backlog 214 * The maximum number of pending connections 215 * 216 * @return This channel 217 * 218 * @throws AlreadyBoundException 219 * If the socket is already bound 220 * @throws UnsupportedAddressTypeException 221 * If the type of the given address is not supported 222 * @throws ClosedChannelException 223 * If this channel is closed 224 * @throws IOException 225 * If some other I/O error occurs 226 * @throws SecurityException 227 * If a security manager has been installed and its {@link 228 * SecurityManager#checkListen checkListen} method denies the 229 * operation 230 * 231 * @since 1.7 232 */ 233 public abstract ServerSocketChannel bind(SocketAddress local, int backlog) 234 throws IOException; 235 236 /** 237 * @throws UnsupportedOperationException {@inheritDoc} 238 * @throws IllegalArgumentException {@inheritDoc} 239 * @throws ClosedChannelException {@inheritDoc} 240 * @throws IOException {@inheritDoc} 241 * 242 * @since 1.7 243 */ 244 public abstract <T> ServerSocketChannel setOption(SocketOption<T> name, T value) 245 throws IOException; 246 247 /** 248 * Retrieves a server socket associated with this channel. 249 * 250 * <p> The returned object will not declare any public methods that are not 251 * declared in the {@link java.net.ServerSocket} class. </p> 252 * 253 * @return A server socket associated with this channel 254 */ 255 public abstract ServerSocket socket(); 256 257 /** 258 * Accepts a connection made to this channel's socket. 259 * 260 * <p> If this channel is in non-blocking mode then this method will 261 * immediately return {@code null} if there are no pending connections. 262 * Otherwise it will block indefinitely until a new connection is available 263 * or an I/O error occurs. 264 * 265 * <p> The socket channel returned by this method, if any, will be in 266 * blocking mode regardless of the blocking mode of this channel. 267 * 268 * <p> This method performs exactly the same security checks as the {@link 269 * java.net.ServerSocket#accept accept} method of the {@link 270 * java.net.ServerSocket} class. That is, if a security manager has been 271 * installed then for each new connection this method verifies that the 272 * address and port number of the connection's remote endpoint are 273 * permitted by the security manager's {@link 274 * java.lang.SecurityManager#checkAccept checkAccept} method. </p> 275 * 276 * @return The socket channel for the new connection, 277 * or {@code null} if this channel is in non-blocking mode 278 * and no connection is available to be accepted 279 * 280 * @throws ClosedChannelException 281 * If this channel is closed 282 * 283 * @throws AsynchronousCloseException 284 * If another thread closes this channel 285 * while the accept operation is in progress 286 * 287 * @throws ClosedByInterruptException 288 * If another thread interrupts the current thread 289 * while the accept operation is in progress, thereby 290 * closing the channel and setting the current thread's 291 * interrupt status 292 * 293 * @throws NotYetBoundException 294 * If this channel's socket has not yet been bound 295 * 296 * @throws SecurityException 297 * If a security manager has been installed 298 * and it does not permit access to the remote endpoint 299 * of the new connection 300 * 301 * @throws IOException 302 * If some other I/O error occurs 303 */ 304 public abstract SocketChannel accept() throws IOException; 305 306 /** 307 * {@inheritDoc} 308 * <p> 309 * If there is a security manager set, its {@code checkConnect} method is 310 * called with the local address and {@code -1} as its arguments to see 311 * if the operation is allowed. If the operation is not allowed, 312 * a {@code SocketAddress} representing the 313 * {@link java.net.InetAddress#getLoopbackAddress loopback} address and the 314 * local port of the channel's socket is returned. 315 * 316 * @return The {@code SocketAddress} that the socket is bound to, or the 317 * {@code SocketAddress} representing the loopback address if 318 * denied by the security manager, or {@code null} if the 319 * channel's socket is not bound 320 * 321 * @throws ClosedChannelException {@inheritDoc} 322 * @throws IOException {@inheritDoc} 323 */ 324 @Override 325 public abstract SocketAddress getLocalAddress() throws IOException; 326 327 } | 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.nio.channels; 27 28 import java.io.IOException; 29 import java.net.NetPermission; 30 import java.net.ProtocolFamily; 31 import java.net.ServerSocket; 32 import java.net.SocketOption; 33 import java.net.SocketAddress; 34 import java.net.UnixDomainSocketAddress; 35 import java.nio.channels.spi.AbstractSelectableChannel; 36 import java.nio.channels.spi.SelectorProvider; 37 import static java.util.Objects.requireNonNull; 38 39 /** 40 * A selectable channel for stream-oriented listening sockets. 41 * 42 * <p> A server-socket channel is created by invoking one of the {@code open} 43 * methods of this class. The no-arg {@link #open() open} method opens a server-socket 44 * channel for an <i>Internet protocol</i> socket. The {@link #open(ProtocolFamily)} 45 * method is used to open a server-socket channel for a socket of a specified 46 * protocol family. It is not possible to create a channel for an arbitrary, 47 * pre-existing socket. A newly-created server-socket channel is open but not yet 48 * bound. An attempt to invoke the {@link #accept() accept} method of an 49 * unbound server-socket channel will cause a {@link NotYetBoundException} 50 * to be thrown. A server-socket channel can be bound by invoking one of the 51 * {@link #bind(java.net.SocketAddress, int) bind} methods defined by this class. 52 * 53 * <p> Socket options are configured using the {@link #setOption(SocketOption,Object) 54 * setOption} method. Server-socket channels for <i>Internet protocol</i> sockets 55 * support the following options: 56 * <blockquote> 57 * <table class="striped"> 58 * <caption style="display:none">Socket options</caption> 59 * <thead> 60 * <tr> 61 * <th scope="col">Option Name</th> 62 * <th scope="col">Description</th> 63 * </tr> 64 * </thead> 65 * <tbody> 66 * <tr> 67 * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th> 68 * <td> The size of the socket receive buffer </td> 69 * </tr> 70 * <tr> 71 * <th scope="row"> {@link java.net.StandardSocketOptions#SO_REUSEADDR SO_REUSEADDR} </th> 72 * <td> Re-use address </td> 73 * </tr> 74 * </tbody> 75 * </table> 76 * </blockquote> 77 * 78 * <p> Server-socket channels for <i>Unix domain</i> sockets support: 79 * <blockquote> 80 * <table class="striped"> 81 * <caption style="display:none">Socket options</caption> 82 * <thead> 83 * <tr> 84 * <th scope="col">Option Name</th> 85 * <th scope="col">Description</th> 86 * </tr> 87 * </thead> 88 * <tbody> 89 * <tr> 90 * <th scope="row"> {@link java.net.StandardSocketOptions#SO_RCVBUF SO_RCVBUF} </th> 91 * <td> The size of the socket receive buffer </td> 92 * </tr> 93 * </tbody> 94 * </table> 95 * </blockquote> 96 * 97 * <p> Additional (implementation specific) options may also be supported. 98 * 99 * <p> Server-socket channels are safe for use by multiple concurrent threads. 100 * </p> 101 * 102 * @author Mark Reinhold 103 * @author JSR-51 Expert Group 104 * @since 1.4 105 */ 106 107 public abstract class ServerSocketChannel 108 extends AbstractSelectableChannel 109 implements NetworkChannel 110 { 111 112 /** 113 * Initializes a new instance of this class. 114 * 115 * @param provider 116 * The provider that created this channel 117 */ 118 protected ServerSocketChannel(SelectorProvider provider) { 119 super(provider); 120 } 121 122 /** 123 * Opens a server-socket channel for an <i>Internet protocol</i> socket. 124 * 125 * <p> The new channel is created by invoking the {@link 126 * java.nio.channels.spi.SelectorProvider#openServerSocketChannel 127 * openServerSocketChannel} method of the system-wide default {@link 128 * java.nio.channels.spi.SelectorProvider} object. 129 * 130 * <p> The new channel's socket is initially unbound; it must be bound to a 131 * specific address via one of its socket's {@link 132 * java.net.ServerSocket#bind(SocketAddress) bind} methods before 133 * connections can be accepted. </p> 134 * 135 * @return A new socket channel 136 * 137 * @throws IOException 138 * If an I/O error occurs 139 * 140 * @see <a href="../../net/doc-files/net-properties.html#Ipv4IPv6"> 141 * java.net.preferIPv4Stack</a> system property 142 */ 143 public static ServerSocketChannel open() throws IOException { 144 return SelectorProvider.provider().openServerSocketChannel(); 145 } 146 147 /** 148 * Opens a server-socket channel. The {@code family} parameter specifies the 149 * {@link ProtocolFamily protocol family} of the channel's socket. 150 * 151 * <p> The new channel is created by invoking the {@link 152 * java.nio.channels.spi.SelectorProvider#openServerSocketChannel(ProtocolFamily) 153 * openServerSocketChannel(ProtocolFamily)} method of the system-wide default {@link 154 * java.nio.channels.spi.SelectorProvider} object. </p> 155 * 156 * @param family 157 * The protocol family 158 * 159 * @return A new socket channel 160 * 161 * @throws UnsupportedOperationException 162 * If the specified protocol family is not supported. For example, 163 * suppose the parameter is specified as {@link 164 * java.net.StandardProtocolFamily#INET6 StandardProtocolFamily.INET6} 165 * but IPv6 is not enabled on the platform. 166 * @throws IOException 167 * If an I/O error occurs 168 * 169 * @see <a href="../../net/doc-files/net-properties.html#Ipv4IPv6"> 170 * java.net.preferIPv4Stack</a> system property 171 * 172 * @since 15 173 */ 174 public static ServerSocketChannel open(ProtocolFamily family) throws IOException { 175 return SelectorProvider.provider().openServerSocketChannel(requireNonNull(family)); 176 } 177 178 /** 179 * Returns an operation set identifying this channel's supported 180 * operations. 181 * 182 * <p> Server-socket channels only support the accepting of new 183 * connections, so this method returns {@link SelectionKey#OP_ACCEPT}. 184 * </p> 185 * 186 * @return The valid-operation set 187 */ 188 public final int validOps() { 189 return SelectionKey.OP_ACCEPT; 190 } 191 195 /** 196 * Binds the channel's socket to a local address and configures the socket 197 * to listen for connections. 198 * 199 * <p> An invocation of this method is equivalent to the following: 200 * <blockquote><pre> 201 * bind(local, 0); 202 * </pre></blockquote> 203 * 204 * @param local 205 * The local address to bind the socket, or {@code null} to bind 206 * to an automatically assigned socket address 207 * 208 * @return This channel 209 * 210 * @throws AlreadyBoundException {@inheritDoc} 211 * @throws UnsupportedAddressTypeException {@inheritDoc} 212 * @throws ClosedChannelException {@inheritDoc} 213 * @throws IOException {@inheritDoc} 214 * @throws SecurityException 215 * If a security manager has been installed and it denies the 216 * operation 217 * 218 * @since 1.7 219 */ 220 public final ServerSocketChannel bind(SocketAddress local) 221 throws IOException 222 { 223 return bind(local, 0); 224 } 225 226 /** 227 * Binds the channel's socket to a local address and configures the socket to 228 * listen for connections. 229 * 230 * <p> This method is used to establish an association between the socket and 231 * a local address. For <i>Internet protocol</i> sockets, once an association 232 * is established then the socket remains bound until the channel is closed. 233 * 234 * <p> The {@code backlog} parameter is the maximum number of pending 235 * connections on the socket. Its exact semantics are implementation specific. 236 * In particular, an implementation may impose a maximum length or may choose 237 * to ignore the parameter altogther. If the {@code backlog} parameter has 238 * the value {@code 0}, or a negative value, then an implementation specific 239 * default is used. 240 * 241 * @apiNote 242 * Binding a server socket channel for a <i>Unix Domain</i> socket, creates a 243 * file corresponding to the file path in the {@link UnixDomainSocketAddress}. 244 * This file persists after the channel is closed, and must be removed before 245 * another socket can bind to the same name. Binding to a {@code null} address 246 * causes the socket to be <i>automatically</i> bound to some unique file 247 * in a system temporary location. The associated socket file also persists 248 * after the channel is closed. Its name can be obtained from the channel's 249 * local socket address. 250 * 251 * @implNote 252 * Each platform enforces an implementation specific, maximum length for the 253 * name of a <i>Unix Domain</i> socket. This limitation is enforced when a 254 * channel is bound. The maximum length is typically close to and generally 255 * not less than 100 bytes. 256 * 257 * @param local 258 * The address to bind the socket, or {@code null} to bind to 259 * an automatically assigned socket address 260 * @param backlog 261 * The maximum number of pending connections 262 * 263 * @return This channel 264 * 265 * @throws AlreadyBoundException 266 * If the socket is already bound 267 * @throws UnsupportedAddressTypeException 268 * If the type of the given address is not supported 269 * @throws ClosedChannelException 270 * If this channel is closed 271 * @throws IOException 272 * If some other I/O error occurs 273 * @throws SecurityException 274 * If a security manager has been installed and its {@link 275 * SecurityManager#checkListen checkListen} method denies 276 * the operation for an <i>Internet protocol</i> socket address, 277 * or for a <i>Unix domain</i> socket address if it denies 278 * {@link NetPermission}{@code("accessUnixDomainSocket")}. 279 * 280 * @since 1.7 281 */ 282 public abstract ServerSocketChannel bind(SocketAddress local, int backlog) 283 throws IOException; 284 285 /** 286 * @throws UnsupportedOperationException {@inheritDoc} 287 * @throws IllegalArgumentException {@inheritDoc} 288 * @throws ClosedChannelException {@inheritDoc} 289 * @throws IOException {@inheritDoc} 290 * 291 * @since 1.7 292 */ 293 public abstract <T> ServerSocketChannel setOption(SocketOption<T> name, T value) 294 throws IOException; 295 296 /** 297 * Retrieves a server socket associated with this channel. 298 * 299 * <p> The returned object will not declare any public methods that are not 300 * declared in the {@link java.net.ServerSocket} class. </p> 301 * 302 * @return A server socket associated with this channel 303 * 304 * @throws UnsupportedOperationException 305 * If the channel's socket is not an <i>Internet protocol</i> socket 306 */ 307 public abstract ServerSocket socket(); 308 309 /** 310 * Accepts a connection made to this channel's socket. 311 * 312 * <p> If this channel is in non-blocking mode then this method will 313 * immediately return {@code null} if there are no pending connections. 314 * Otherwise it will block indefinitely until a new connection is available 315 * or an I/O error occurs. 316 * 317 * <p> The socket channel returned by this method, if any, will be in 318 * blocking mode regardless of the blocking mode of this channel. 319 * 320 * <p> If bound to an <i>Internet protocol</i> socket address, this method 321 * performs exactly the same security checks as the {@link 322 * java.net.ServerSocket#accept accept} method of the {@link java.net.ServerSocket} 323 * class. That is, if a security manager has been installed then for each 324 * new connection this method verifies that the address and port number 325 * of the connection's remote endpoint are permitted by the security 326 * manager's {@link java.lang.SecurityManager#checkAccept checkAccept} 327 * method. If bound to a <i>Unix Domain</i> socket address, this method checks 328 * {@link NetPermission}{@code ("accessUnixDomainSocket")}. 329 * 330 * @return The socket channel for the new connection, 331 * or {@code null} if this channel is in non-blocking mode 332 * and no connection is available to be accepted 333 * 334 * @throws ClosedChannelException 335 * If this channel is closed 336 * 337 * @throws AsynchronousCloseException 338 * If another thread closes this channel 339 * while the accept operation is in progress 340 * 341 * @throws ClosedByInterruptException 342 * If another thread interrupts the current thread 343 * while the accept operation is in progress, thereby 344 * closing the channel and setting the current thread's 345 * interrupt status 346 * 347 * @throws NotYetBoundException 348 * If this channel's socket has not yet been bound 349 * 350 * @throws SecurityException 351 * If a security manager has been installed 352 * and it does not permit access to the remote endpoint 353 * of the new connection 354 * 355 * @throws IOException 356 * If some other I/O error occurs 357 */ 358 public abstract SocketChannel accept() throws IOException; 359 360 /** 361 * {@inheritDoc} 362 * 363 * If there is a security manager set, its {@code checkConnect} method is 364 * called with the local address and {@code -1} as its arguments to see 365 * if the operation is allowed. If the operation is not allowed, 366 * a {@code SocketAddress} representing the 367 * {@link java.net.InetAddress#getLoopbackAddress loopback} address and the 368 * local port of the channel's socket is returned. 369 * 370 * <p> Where the channel is bound to a <i>Unix Domain</i> socket address, the socket 371 * address is a {@link UnixDomainSocketAddress}. If there is a security manager 372 * set, its {@link SecurityManager#checkPermission(java.security.Permission) 373 * checkPermission} method is called with {@link NetPermission}{@code 374 * ("accessUnixDomainSocket")}. If the operation is not allowed an unnamed 375 * {@link UnixDomainSocketAddress} is returned. 376 * 377 * @return The {@code SocketAddress} that the socket is bound to, or the 378 * {@code SocketAddress} representing the loopback address or empty 379 * path if denied by the security manager, or {@code null} if the 380 * channel's socket is not bound 381 * 382 * @throws ClosedChannelException {@inheritDoc} 383 * @throws IOException {@inheritDoc} 384 */ 385 @Override 386 public abstract SocketAddress getLocalAddress() throws IOException; 387 } |