1 |
/* ServerSocket.java -- Class for implementing server side sockets |
/* ServerSocket.java -- Class for implementing server side sockets |
2 |
Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
35 |
obligated to do so. If you do not wish to do so, delete this |
obligated to do so. If you do not wish to do so, delete this |
36 |
exception statement from your version. */ |
exception statement from your version. */ |
37 |
|
|
38 |
|
|
39 |
package java.net; |
package java.net; |
40 |
|
|
41 |
import gnu.java.net.PlainSocketImpl; |
import gnu.java.net.PlainSocketImpl; |
73 |
*/ |
*/ |
74 |
private SocketImpl impl; |
private SocketImpl impl; |
75 |
|
|
|
/** |
|
|
* ServerSocketChannel of this ServerSocket. This channel only exists |
|
|
* when the socket is created by ServerSocketChannel.open(). |
|
|
*/ |
|
|
private ServerSocketChannel ch; |
|
|
|
|
76 |
private boolean closed = false; |
private boolean closed = false; |
77 |
|
|
78 |
/** |
/** |
154 |
bind (new InetSocketAddress (bindAddr, port), backlog); |
bind (new InetSocketAddress (bindAddr, port), backlog); |
155 |
} |
} |
156 |
|
|
|
/* |
|
|
* This method may only be used by java.nio.channels.ServerSocketChannel.open. |
|
|
*/ |
|
|
void setChannel (ServerSocketChannel ch) |
|
|
{ |
|
|
this.ch = ch; |
|
|
} |
|
|
|
|
157 |
/** |
/** |
158 |
* Binds the server socket to a specified socket address |
* Binds the server socket to a specified socket address |
159 |
* |
* |
304 |
protected final void implAccept (Socket s) |
protected final void implAccept (Socket s) |
305 |
throws IOException |
throws IOException |
306 |
{ |
{ |
307 |
if (ch != null && !ch.isBlocking()) |
if (getChannel() != null |
308 |
|
&& !getChannel().isBlocking()) |
309 |
throw new IllegalBlockingModeException(); |
throw new IllegalBlockingModeException(); |
310 |
|
|
311 |
impl.accept(s.impl); |
impl.accept(s.impl); |
321 |
if (impl != null) |
if (impl != null) |
322 |
impl.close (); |
impl.close (); |
323 |
|
|
324 |
if (ch != null) |
if (getChannel() != null) |
325 |
ch.close (); |
getChannel().close (); |
326 |
|
|
327 |
closed = true; |
closed = true; |
328 |
} |
} |
338 |
*/ |
*/ |
339 |
public ServerSocketChannel getChannel() |
public ServerSocketChannel getChannel() |
340 |
{ |
{ |
341 |
return ch; |
return null; |
342 |
} |
} |
343 |
|
|
344 |
/** |
/** |