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