View Javadoc
1   /*
2    * junixsocket
3    *
4    * Copyright 2009-2024 Christian Kohlschütter
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.newsclub.net.unix;
19  
20  import java.io.Closeable;
21  import java.net.DatagramSocket;
22  import java.net.ServerSocket;
23  import java.net.Socket;
24  import java.net.SocketAddress;
25  import java.nio.channels.DatagramChannel;
26  import java.nio.channels.ServerSocketChannel;
27  import java.nio.channels.SocketChannel;
28  
29  import org.eclipse.jdt.annotation.Nullable;
30  
31  /**
32   * Marker interface that combines junixsocket-based {@link SocketChannel}s, {@link Socket}s,
33   * {@link DatagramChannel}s and {@link DatagramSocket}s, as well as {@link ServerSocket}s and
34   * {@link ServerSocketChannel}s.
35   *
36   * @author Christian Kohlschütter
37   * @see AFSocketPair
38   * @see AFSocket
39   * @see AFSocketChannel
40   * @see AFDatagramSocket
41   * @see AFDatagramChannel
42   * @see AFServerSocket
43   * @see AFServerSocketChannel
44   */
45  public interface AFSomeSocketThing extends Closeable, FileDescriptorAccess {
46    /**
47     * Returns the socket's local socket address, or {@code null} if unavailable or if there was a
48     * problem retrieving it.
49     *
50     * @return The local socket address, or {@code null}.
51     */
52    @Nullable
53    SocketAddress getLocalSocketAddress();
54  
55    /**
56     * Configures whether the socket should be shutdown upon {@link #close()}, which is the default.
57     *
58     * @param enabled {@code true} if enabled.
59     */
60    void setShutdownOnClose(boolean enabled);
61  }