summaryrefslogtreecommitdiff
path: root/gnu/java/nio/ServerSocketChannelImpl.java
blob: ef93dff48b5d8d2cec27021e681d7d4fa2505fde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package gnu.java.nio;

import java.io.*;
import java.nio.channels.spi.*;
import java.nio.channels.*;
import java.net.*;

class ServerSocketChannelImpl extends ServerSocketChannel
{
    ServerSocket sock_object;
    int fd;
    int local_port;
    boolean blocking = true;
    boolean connected = false;
    InetSocketAddress sa;

    private static native int NioSocketAccept(ServerSocketChannelImpl server, 
					      SocketChannelImpl s);

    protected ServerSocketChannelImpl(SelectorProvider provider)
    {
	super(provider);
	fd = SocketChannelImpl.SocketCreate();
    }
 
    public void finalizer()
    {
	if (connected)
	    {
		try {
		    close();
		} catch (Exception e) {
		}
	    }
    }

    protected void implCloseSelectableChannel()
    {
	connected = false;
	SocketChannelImpl.SocketClose(fd);
	fd = SocketChannelImpl.SocketCreate();
    }

    protected void implConfigureBlocking(boolean  block)
    {
    }

    public SocketChannel accept()
    {
	SocketChannelImpl result = new SocketChannelImpl(provider());
	    
	result.sa = new InetSocketAddress(0);
	
	int res = NioSocketAccept(this, result);
	
	return result;
    }

    public ServerSocket socket()
    {
	return null;
    }
}