2
|
1 package rep;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.net.InetSocketAddress;
|
|
5 import java.nio.channels.SocketChannel;
|
|
6
|
135
|
7 import rep.channel.REPSocketChannel;
|
|
8
|
2
|
9 public class SMConnector {
|
135
|
10 private REPSocketChannel<REPCommand> sessionchannel;
|
2
|
11
|
|
12 public void connectSession(String host) {
|
|
13 int port = 8765;
|
|
14 //int port = Integer.parseInt(args[2]);
|
|
15 InetSocketAddress addr = new InetSocketAddress(host, port);
|
|
16 try {
|
135
|
17 sessionchannel = REPSocketChannel.open();
|
2
|
18 sessionchannel.configureBlocking(true);
|
|
19 sessionchannel.connect(addr);
|
|
20 System.out.println("connect");
|
|
21 //sessionchannel.configureBlocking(false);
|
|
22 while(!sessionchannel.finishConnect()){
|
|
23 System.out.println("afro");
|
|
24 }
|
|
25 //registerChannel(selector, sessionchannel, SelectionKey.OP_READ);
|
|
26 }catch (IOException e) {
|
|
27 e.printStackTrace();
|
|
28 }
|
|
29 }
|
|
30 }
|