comparison rep/simulator/ServerChannelSimulator.java @ 123:5b1a0574b406 add-simulator

*** empty log message ***
author pin
date Wed, 27 Aug 2008 17:21:25 +0900
parents
children
comparison
equal deleted inserted replaced
122:790c8dd42a7b 123:5b1a0574b406
1 package rep.simulator;
2
3 import java.io.IOException;
4 import java.nio.channels.ClosedChannelException;
5 import java.nio.channels.SelectableChannel;
6 import java.nio.channels.SelectionKey;
7 import java.nio.channels.Selector;
8 import java.nio.channels.spi.SelectorProvider;
9
10
11
12 public class ServerChannelSimulator<P>extends SelectableChannelSimulator<P>{
13 protected NetworkSimulator<P> ns;
14 private int virtualIP;
15
16 /** Constructors. */
17 public ServerChannelSimulator(NetworkSimulator<P> _ns, SelectorSimulator<P> rselector){
18 ns = _ns;
19 readSelector = rselector;
20 writeSelector = null;
21 qread = null;
22 qwrite = null;
23 }
24
25 /** Connecting methods */
26 // for servers.
27 public void bind(int ip){
28 virtualIP = ip;
29 ns.listen(ip, readSelector);
30 }
31
32 public ChannelSimulator<P> accept(){
33 ChannelSimulator<P> channel = ns.accept(virtualIP);
34 return channel;
35 }
36
37
38 /* state check methods for SelectionKeySimulator. */
39 public boolean isReadable() {
40 return false;
41 }
42 public boolean isWritable() {
43 return false;
44 }
45 public boolean isAcceptable() {
46 return ns.canAccept(virtualIP);
47 }
48
49 @Override
50 public Object blockingLock() {
51 // TODO Auto-generated method stub
52 return null;
53 }
54
55 @Override
56 public SelectableChannel configureBlocking(boolean block) throws IOException {
57 // TODO Auto-generated method stub
58 return null;
59 }
60
61 @Override
62 public boolean isBlocking() {
63 // TODO Auto-generated method stub
64 return false;
65 }
66
67 @Override
68 public boolean isRegistered() {
69 // TODO Auto-generated method stub
70 return false;
71 }
72
73 @Override
74 public SelectionKey keyFor(Selector sel) {
75 // TODO Auto-generated method stub
76 return null;
77 }
78
79 @Override
80 public SelectorProvider provider() {
81 // TODO Auto-generated method stub
82 return null;
83 }
84
85 @Override
86 public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException {
87 // TODO Auto-generated method stub
88 return null;
89 }
90
91 @Override
92 public int validOps() {
93 // TODO Auto-generated method stub
94 return 0;
95 }
96
97 @Override
98 protected void implCloseChannel() throws IOException {
99 // TODO Auto-generated method stub
100
101 }
102
103 }