1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.newsclub.net.unix;
19
20 import java.io.File;
21 import java.io.FileDescriptor;
22 import java.io.IOException;
23 import java.net.ServerSocket;
24 import java.net.SocketException;
25 import java.nio.file.Path;
26
27
28
29
30
31
32 public final class AFUNIXServerSocket extends AFServerSocket<AFUNIXSocketAddress> {
33
34
35
36
37
38 protected AFUNIXServerSocket() throws IOException {
39 super();
40 }
41
42
43
44
45
46
47
48 AFUNIXServerSocket(FileDescriptor fdObj) throws IOException {
49 super(fdObj);
50 }
51
52 @Override
53 protected AFUNIXServerSocketChannel newChannel() {
54 return new AFUNIXServerSocketChannel(this);
55 }
56
57 @Override
58 public AFUNIXServerSocketChannel getChannel() {
59 return (AFUNIXServerSocketChannel) super.getChannel();
60 }
61
62
63
64
65
66
67
68 public static AFUNIXServerSocket newInstance() throws IOException {
69 return (AFUNIXServerSocket) AFServerSocket.newInstance(AFUNIXServerSocket::new);
70 }
71
72 static AFUNIXServerSocket newInstance(FileDescriptor fdObj, int localPort, int remotePort)
73 throws IOException {
74 return (AFUNIXServerSocket) AFServerSocket.newInstance(AFUNIXServerSocket::new, fdObj,
75 localPort, remotePort);
76 }
77
78
79
80
81
82
83
84
85
86 public static AFUNIXServerSocket bindOn(final AFUNIXSocketAddress addr) throws IOException {
87 return (AFUNIXServerSocket) AFServerSocket.bindOn(AFUNIXServerSocket::new, addr);
88 }
89
90
91
92
93
94
95
96
97
98
99 public static AFUNIXServerSocket bindOn(final AFUNIXSocketAddress addr, boolean deleteOnClose)
100 throws IOException {
101 return (AFUNIXServerSocket) AFServerSocket.bindOn(AFUNIXServerSocket::new, addr, deleteOnClose);
102 }
103
104
105
106
107
108
109
110
111
112 public static AFUNIXServerSocket bindOn(final File path, boolean deleteOnClose)
113 throws IOException {
114 return bindOn(path.toPath(), deleteOnClose);
115 }
116
117
118
119
120
121
122
123
124
125 public static AFUNIXServerSocket bindOn(final Path path, boolean deleteOnClose)
126 throws IOException {
127 return (AFUNIXServerSocket) AFServerSocket.bindOn(AFUNIXServerSocket::new, AFUNIXSocketAddress
128 .of(path), deleteOnClose);
129 }
130
131
132
133
134
135
136
137
138
139 public static AFUNIXServerSocket forceBindOn(final AFUNIXSocketAddress forceAddr)
140 throws IOException {
141 return (AFUNIXServerSocket) AFServerSocket.forceBindOn(AFUNIXServerSocket::new, forceAddr);
142 }
143
144 @Override
145 protected AFSocketImpl<AFUNIXSocketAddress> newImpl(FileDescriptor fdObj) throws SocketException {
146 return new AFUNIXSocketImpl(fdObj);
147 }
148
149
150
151
152
153
154
155 @Override
156 protected AFUNIXSocket newSocketInstance() throws IOException {
157 return AFUNIXSocket.newInstance();
158 }
159
160 @Override
161 public AFUNIXSocket accept() throws IOException {
162 return (AFUNIXSocket) super.accept();
163 }
164 }