view rep/net/REPNet.java @ 84:54334d83194a

*** empty log message ***
author pin
date Fri, 21 Dec 2007 16:03:04 +0900
parents 91a33a634fef
children 8dce4348966c
line wrap: on
line source

package rep.net;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;

import rep.REPCommand;
import rep.REPPacketReceive;
import rep.REPPacketSend;

public class REPNet {
	private SocketChannel sc;
	private REPPacketReceive repreceive;
	private REPPacketSend repsend;

	public void sm_connect(String host, int port){
		//int port = 8765;
		//String host = "localhost";
		InetSocketAddress addr = new InetSocketAddress(host, port);
		try {
			sc = SocketChannel.open();
			sc.configureBlocking(true);
			sc.connect(addr);
			while(!sc.finishConnect()){
				System.out.println("afro");
			}
		}catch (IOException e) {
			e.printStackTrace();
		}
		repreceive = new REPPacketReceive(sc);
		repsend = new REPPacketSend(sc);
	}

	public void send(REPCommand command) {
		// TODO Auto-generated method stub
		repsend.send(command);
	}
}