view src/fdl/old/test/metaTransfer/TestSend.java @ 114:3b877c9a44f5

gather old packages
author kazz
date Mon, 11 Oct 2010 14:29:37 +0900
parents src/fdl/test/metaTransfer/TestSend.java@629b6cfbd37f
children
line wrap: on
line source

package fdl.old.test.metaTransfer;

import java.io.IOException;
import java.nio.ByteBuffer;

import fdl.FederatedLinda;
import fdl.PSXLinda;

public class TestSend extends Thread {
	PSXLinda psxsend;
	FederatedLinda fdlsend;
	
	public void run(){
		int id = 10;
		int port = 10001;
		boolean connect = true;
		String host = "127.0.0.1";
		ByteBuffer send = ByteBuffer.allocate(1024);
		send.putInt(12);
		send.flip();
		while(connect){
		try {
		sendData(id, port, host, send);
		connect = false;
		} catch(IOException e) {
			try {
				Thread.sleep(40);
			} catch (InterruptedException e1) {
				e1.printStackTrace();
			}
		}
		
		}
	}

	private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
		fdlsend = FederatedLinda.init();

			psxsend = fdlsend.open(host,port);
			System.out.println("Connect Host1");
			psxsend.out(id, send);
			fdlsend.sync(1);
			System.out.println("Send Data");

	}
	
}