view test/channeltest/testEditor.java @ 500:66096af6a0e0

Added tag global-seq-sort for changeset 4bcc6b563d52
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 Oct 2010 11:23:21 +0900
parents 1eec69035548
children
line wrap: on
line source

package test.channeltest;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

import rep.channel.REPLogger;
import rep.channel.REPSocketChannel;


public class testEditor extends Thread{
	private SocketAddress semaIP;
	private REPLogger ns;
	
	public testEditor(String name, String _host,int _port){
		super(name);
		semaIP = new InetSocketAddress(_host, _port);
		ns = REPLogger.singleton();
	}

	public void run(){
		try {
			REPSocketChannel<String> channel;
			channel = REPSocketChannel.<String>create(new StringPacker());
			channel.configureBlocking(true);

			ns.writeLog("try to connect to SessionManager whose ip is "+semaIP, 1);
			while (!channel.connect(semaIP)){
				ns.writeLog("SeMa not listen to socket yet, wait", 1);
				Thread.yield();
			}
			ns.writeLog("successes to connect", 1);

			channel.write(getName()+": send hello");
			ns.writeLog("wrote packet", 1);

			String packet = channel.read();

			ns.writeLog("gets return string==> `"+packet+"\'", 1);

			ns.writeLog("testEditor exits.", 1);
		} catch (IOException e) {
		}
	}
}