view src/fdl/test/metaTransfer/Ring/TestSend.java @ 53:629b6cfbd37f

metaprotocol ring
author axmo
date Mon, 19 Jan 2009 17:49:14 +0900
parents
children
line wrap: on
line source

package fdl.test.metaTransfer.Ring;

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");

	}
	
}