2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * A UNIX-domain (AF_LOCAL) socket address. For use with
21 * android.net.LocalSocket and android.net.LocalServerSocket.
23 * On the Android system, these names refer to names in the Linux
24 * abstract (non-filesystem) UNIX domain namespace.
26 public class LocalSocketAddress
29 * The namespace that this address exists in. See also
30 * include/cutils/sockets.h ANDROID_SOCKET_NAMESPACE_*
32 public enum Namespace {
33 /** A socket in the Linux abstract namespace */
36 * A socket in the Android reserved namespace in /dev/socket.
37 * Only the init process may create a socket here.
41 * A socket named with a normal filesystem path.
45 /** The id matches with a #define in include/cutils/sockets.h */
52 * @return int constant shared with native code
54 /*package*/ int getId() {
59 private final String name;
60 private final Namespace namespace;
63 * Creates an instance with a given name.
65 * @param name non-null name
66 * @param namespace namespace the name should be created in.
68 public LocalSocketAddress(String name, Namespace namespace) {
70 this.namespace = namespace;
74 * Creates an instance with a given name in the {@link Namespace#ABSTRACT}
77 * @param name non-null name
79 public LocalSocketAddress(String name) {
80 this(name,Namespace.ABSTRACT);
84 * Retrieves the string name of this address
87 public String getName()
93 * Returns the namespace used by this address.
95 * @return non-null a namespace
97 public Namespace getNamespace() {