annotate rep/SMConnector.java @ 137:1ea856259add

*** empty log message ***
author pin
date Wed, 27 Aug 2008 18:43:09 +0900
parents 0bd4ffc33bdb
children a776ec9ed848
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
1 package rep;
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
2
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
3 import java.io.IOException;
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
4 import java.net.InetSocketAddress;
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
5 import java.nio.channels.SocketChannel;
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
6
135
0bd4ffc33bdb *** empty log message ***
kent
parents: 2
diff changeset
7 import rep.channel.REPSocketChannel;
0bd4ffc33bdb *** empty log message ***
kent
parents: 2
diff changeset
8
2
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
9 public class SMConnector {
135
0bd4ffc33bdb *** empty log message ***
kent
parents: 2
diff changeset
10 private REPSocketChannel<REPCommand> sessionchannel;
2
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
11
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
12 public void connectSession(String host) {
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
13 int port = 8765;
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
14 //int port = Integer.parseInt(args[2]);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
15 InetSocketAddress addr = new InetSocketAddress(host, port);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
16 try {
135
0bd4ffc33bdb *** empty log message ***
kent
parents: 2
diff changeset
17 sessionchannel = REPSocketChannel.open();
2
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
18 sessionchannel.configureBlocking(true);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
19 sessionchannel.connect(addr);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
20 System.out.println("connect");
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
21 //sessionchannel.configureBlocking(false);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
22 while(!sessionchannel.finishConnect()){
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
23 System.out.println("afro");
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
24 }
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
25 //registerChannel(selector, sessionchannel, SelectionKey.OP_READ);
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
26 }catch (IOException e) {
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
27 e.printStackTrace();
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
28 }
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
29 }
02fa9a68d9a2 *** empty log message ***
pin
parents:
diff changeset
30 }