1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44:
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51: import ;
52: import ;
53:
54:
58: public final class LocalSocket extends Socket
59: {
60:
61:
62:
63:
64: private final LocalSocketImpl localimpl;
65: boolean localClosed;
66: boolean localConnected;
67:
68:
69:
70:
71: public LocalSocket () throws SocketException
72: {
73: super ();
74: localimpl = new LocalSocketImpl ();
75: }
76:
77: public LocalSocket (LocalSocketAddress addr) throws SocketException
78: {
79: this ();
80: try
81: {
82: connect (addr);
83: }
84: catch (IOException ioe)
85: {
86: SocketException se = new SocketException ();
87: se.initCause (ioe);
88: throw se;
89: }
90: }
91:
92: LocalSocket (boolean nocreate) throws IOException
93: {
94: super ();
95: localimpl = new LocalSocketImpl (nocreate);
96: }
97:
98:
99:
100:
101: public void bind (SocketAddress bindpoint) throws IOException
102: {
103: throw new SocketException ("binding local client sockets is nonsensical");
104: }
105:
106: public void connect (SocketAddress endpoint, int timeout) throws IOException
107: {
108: if (isClosed ())
109: {
110: throw new SocketException ("socket is closed");
111: }
112: if (! (endpoint instanceof LocalSocketAddress))
113: {
114: throw new IllegalArgumentException ("socket address is not a local address");
115: }
116: if (getChannel() != null && !getChannel().isBlocking())
117: {
118: throw new IllegalBlockingModeException ();
119: }
120:
121: try
122: {
123: localimpl.doCreate ();
124: localimpl.localConnect ((LocalSocketAddress) endpoint);
125: }
126: catch (IOException ioe)
127: {
128: close ();
129: throw ioe;
130: }
131: localConnected = true;
132: }
133:
134: public InetAddress getInetAddress ()
135: {
136: return null;
137: }
138:
139: public InetAddress getLocalAddress ()
140: {
141: return null;
142: }
143:
144: public int getPort ()
145: {
146: return -1;
147: }
148:
149: public int getLocalPort ()
150: {
151: return -1;
152: }
153:
154: public SocketChannel getChannel ()
155: {
156: return null;
157: }
158:
159: public SocketAddress getLocalSocketAddress ()
160: {
161: return localimpl.getLocalAddress ();
162: }
163:
164: public SocketAddress getRemoteSocketAddress ()
165: {
166: return localimpl.getRemoteAddress ();
167: }
168:
169: public InputStream getInputStream () throws IOException
170: {
171: return localimpl.getInputStream ();
172: }
173:
174: public OutputStream getOutputStream () throws IOException
175: {
176: return localimpl.getOutputStream ();
177: }
178:
179: public void sendUrgentData (int b) throws IOException
180: {
181: localimpl.sendUrgentData (b);
182: }
183:
184: public synchronized void close () throws IOException
185: {
186: localimpl.close ();
187: localClosed = true;
188: }
189:
190: public void shutdownInput () throws IOException
191: {
192: localimpl.shutdownInput ();
193: }
194:
195: public void shutdownOutput () throws IOException
196: {
197: localimpl.shutdownOutput ();
198: }
199:
200: public boolean isClosed ()
201: {
202: return localClosed;
203: }
204:
205: public boolean isBound ()
206: {
207: return false;
208: }
209:
210: public boolean isConnected ()
211: {
212: return localConnected;
213: }
214:
215:
216:
217:
218: public void setTcpNoDelay (boolean b) throws SocketException
219: {
220: throw new SocketException ("local sockets do not support this option");
221: }
222:
223: public boolean getTcpNoDelay() throws SocketException
224: {
225: throw new SocketException ("local sockets do not support this option");
226: }
227:
228: public void setSoLinger (boolean b, int i) throws SocketException
229: {
230: throw new SocketException ("local sockets do not support this option");
231: }
232:
233: public int getSoLinger () throws SocketException
234: {
235: throw new SocketException ("local sockets do not support this option");
236: }
237:
238: public void setOOBInline (boolean b) throws SocketException
239: {
240: throw new SocketException ("local sockets do not support this option");
241: }
242:
243: public boolean getOOBInline () throws SocketException
244: {
245: throw new SocketException ("local sockets do not support this option");
246: }
247:
248: public void setSoTimeout (int i) throws SocketException
249: {
250:
251: }
252:
253: public int getSoTimeout () throws SocketException
254: {
255:
256: return 0;
257: }
258:
259: public void setSendBufferSize (int i) throws SocketException
260: {
261: throw new SocketException ("local sockets do not support this option");
262: }
263:
264: public int getSendBufferSize() throws SocketException
265: {
266: throw new SocketException ("local sockets do not support this option");
267: }
268:
269: public void setReceiveBufferSize (int i) throws SocketException
270: {
271: throw new SocketException ("local sockets do not support this option");
272: }
273:
274: public int getReceiveBufferSize () throws SocketException
275: {
276: throw new SocketException ("local sockets do not support this option");
277: }
278:
279: public void setKeepAlive (boolean b) throws SocketException
280: {
281: throw new SocketException ("local sockets do not support this option");
282: }
283:
284: public boolean getKeepAlive () throws SocketException
285: {
286: throw new SocketException ("local sockets do not support this option");
287: }
288:
289: public void setTrafficClass (int i) throws SocketException
290: {
291: throw new SocketException ("local sockets do not support this option");
292: }
293:
294: public int getTrafficClass () throws SocketException
295: {
296: throw new SocketException ("local sockets do not support this option");
297: }
298:
299: public void setReuseAddress (boolean b) throws SocketException
300: {
301: throw new SocketException ("local sockets do not support this option");
302: }
303:
304: public boolean getReuseAddress () throws SocketException
305: {
306: throw new SocketException ("local sockets do not support this option");
307: }
308:
309: LocalSocketImpl getLocalImpl ()
310: {
311: return localimpl;
312: }
313: }