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 gnu.java.nio; |
package gnu.java.nio; |
40 |
|
|
41 |
import java.io.IOException; |
import java.io.IOException; |
42 |
import java.net.InetSocketAddress; |
import java.net.InetSocketAddress; |
43 |
import java.net.ServerSocket; |
import java.net.ServerSocket; |
44 |
|
import java.net.Socket; |
45 |
import java.net.SocketAddress; |
import java.net.SocketAddress; |
46 |
import java.nio.channels.ServerSocketChannel; |
import java.nio.channels.ServerSocketChannel; |
47 |
import java.nio.channels.SocketChannel; |
import java.nio.channels.SocketChannel; |
49 |
|
|
50 |
class ServerSocketChannelImpl extends ServerSocketChannel |
class ServerSocketChannelImpl extends ServerSocketChannel |
51 |
{ |
{ |
52 |
ServerSocket sock_object; |
ServerSocket serverSocket; |
|
int fd; |
|
|
int local_port; |
|
53 |
boolean blocking = true; |
boolean blocking = true; |
54 |
boolean connected = false; |
boolean connected = false; |
|
InetSocketAddress sa; |
|
|
|
|
|
private static int NioSocketAccept (ServerSocketChannelImpl server, |
|
|
SocketChannelImpl s) |
|
|
{ |
|
|
return 0; |
|
|
} |
|
55 |
|
|
56 |
protected ServerSocketChannelImpl (SelectorProvider provider) |
protected ServerSocketChannelImpl (SelectorProvider provider) |
57 |
throws IOException |
throws IOException |
58 |
{ |
{ |
59 |
super (provider); |
super (provider); |
60 |
fd = SocketChannelImpl.SocketCreate (); |
serverSocket = new ServerSocket (); |
|
|
|
|
try |
|
|
{ |
|
|
sock_object = new ServerSocket (); |
|
|
} |
|
|
catch (IOException e) |
|
|
{ |
|
|
System.err.println ("ServerSocket could not be created."); |
|
|
} |
|
61 |
} |
} |
62 |
|
|
63 |
public void finalizer() |
public void finalizer() |
77 |
protected void implCloseSelectableChannel () throws IOException |
protected void implCloseSelectableChannel () throws IOException |
78 |
{ |
{ |
79 |
connected = false; |
connected = false; |
80 |
SocketChannelImpl.SocketClose (fd); |
serverSocket.close(); |
|
fd = SocketChannelImpl.SocketCreate (); |
|
81 |
} |
} |
82 |
|
|
83 |
protected void implConfigureBlocking (boolean blocking) throws IOException |
protected void implConfigureBlocking (boolean blocking) throws IOException |
84 |
{ |
{ |
85 |
this.blocking = blocking; |
this.blocking = blocking; // FIXME |
86 |
} |
} |
87 |
|
|
88 |
public SocketChannel accept () throws IOException |
public SocketChannel accept () throws IOException |
89 |
{ |
{ |
90 |
SocketChannelImpl result = new SocketChannelImpl (provider ()); |
SocketChannelImpl result = new SocketChannelImpl (provider ()); |
91 |
result.sa = new InetSocketAddress (0); |
Socket socket = serverSocket.accept(); |
92 |
int res = NioSocketAccept (this, result); |
//socket.setChannel (result); // FIXME |
93 |
return result; |
return result; |
94 |
} |
} |
95 |
|
|
96 |
public ServerSocket socket () |
public ServerSocket socket () |
97 |
{ |
{ |
98 |
return sock_object; |
return serverSocket; |
99 |
} |
} |
100 |
} |
} |