37 |
|
|
38 |
package gnu.java.nio; |
package gnu.java.nio; |
39 |
|
|
40 |
import java.io.*; |
import java.net.InetSocketAddress; |
41 |
import java.nio.channels.spi.*; |
import java.net.ServerSocket; |
42 |
import java.nio.channels.*; |
import java.net.SocketAddress; |
43 |
import java.net.*; |
import java.nio.channels.ServerSocketChannel; |
44 |
|
import java.nio.channels.SocketChannel; |
45 |
|
import java.nio.channels.spi.SelectorProvider; |
46 |
|
|
47 |
class ServerSocketChannelImpl extends ServerSocketChannel |
class ServerSocketChannelImpl extends ServerSocketChannel |
48 |
{ |
{ |
49 |
ServerSocket sock_object; |
ServerSocket sock_object; |
50 |
int fd; |
int fd; |
51 |
int local_port; |
int local_port; |
52 |
boolean blocking = true; |
boolean blocking = true; |
53 |
boolean connected = false; |
boolean connected = false; |
54 |
InetSocketAddress sa; |
InetSocketAddress sa; |
55 |
|
|
56 |
private static native int NioSocketAccept(ServerSocketChannelImpl server, |
/* |
57 |
SocketChannelImpl s); |
private static native int NioSocketAccept (ServerSocketChannelImpl server, |
58 |
|
SocketChannelImpl s); |
59 |
protected ServerSocketChannelImpl(SelectorProvider provider) |
*/ |
60 |
{ |
|
61 |
super(provider); |
private static int NioSocketAccept (ServerSocketChannelImpl server, |
62 |
fd = SocketChannelImpl.SocketCreate(); |
SocketChannelImpl s) |
63 |
} |
{ |
64 |
|
return 0; |
65 |
|
} |
66 |
|
|
67 |
|
protected ServerSocketChannelImpl (SelectorProvider provider) |
68 |
|
{ |
69 |
|
super (provider); |
70 |
|
fd = SocketChannelImpl.SocketCreate (); |
71 |
|
} |
72 |
|
|
73 |
public void finalizer() |
public void finalizer() |
74 |
{ |
{ |
75 |
if (connected) |
if (connected) |
76 |
{ |
{ |
77 |
try { |
try |
78 |
close(); |
{ |
79 |
} catch (Exception e) { |
close(); |
80 |
} |
} |
81 |
|
catch (Exception e) |
82 |
|
{ |
83 |
|
} |
84 |
} |
} |
85 |
} |
} |
86 |
|
|
87 |
protected void implCloseSelectableChannel() |
protected void implCloseSelectableChannel () |
88 |
{ |
{ |
89 |
connected = false; |
connected = false; |
90 |
SocketChannelImpl.SocketClose(fd); |
SocketChannelImpl.SocketClose (fd); |
91 |
fd = SocketChannelImpl.SocketCreate(); |
fd = SocketChannelImpl.SocketCreate (); |
92 |
} |
} |
93 |
|
|
94 |
protected void implConfigureBlocking(boolean block) |
protected void implConfigureBlocking (boolean block) |
95 |
{ |
{ |
96 |
} |
} |
97 |
|
|
98 |
public SocketChannel accept() |
public SocketChannel accept () |
99 |
{ |
{ |
100 |
SocketChannelImpl result = new SocketChannelImpl(provider()); |
SocketChannelImpl result = new SocketChannelImpl (provider ()); |
101 |
|
result.sa = new InetSocketAddress (0); |
102 |
result.sa = new InetSocketAddress(0); |
int res = NioSocketAccept (this, result); |
103 |
|
return result; |
104 |
int res = NioSocketAccept(this, result); |
} |
105 |
|
|
106 |
return result; |
public ServerSocket socket () |
107 |
} |
{ |
108 |
|
return sock_object; |
109 |
public ServerSocket socket() |
} |
|
{ |
|
|
return null; |
|
|
} |
|
110 |
} |
} |