import ByteConverter;
import java.io.*;
import java.net.*;

public class synesm {
    
    public static void usage() {
	System.err.println("usage: java synesm inputtextfile");
	System.exit(1);
    }
    
    public static void main(String[] args) {
	int error = 0;
	if (args.length != 1) {
	    synesm.usage();
	}
	
	// tobago -> 128.2.185.113
	// deforrest -> 128.2.237.71
	try {
      
    //send IP addresses and IP multicast address/port to ESM
	ByteArrayOutputStream bout = new ByteArrayOutputStream();
	DataOutputStream out = new DataOutputStream(bout);

	Socket ESMsock = new Socket(InetAddress.getByName("128.2.220.119"),
			       5005);	
    //need to invoke proxy and vic on end hosts...hmmm...

	// receive OK from ESM proxy setup
	
	// send commit to video Gateway and ESM
	
	String myString = new String("vic 239.255.20.229/60760 &");
	//	InetAddress ipaddress = new
	//	String myString = new String("xterm &");
	System.out.println("length is " + myString.length());
	//	out.write(myString.getBytes("ASCII"), 0, myString.length());
	out.writeInt(13);
	out.write((InetAddress.getByName("orlando.cmcl.cs.cmu.edu")).getAddress(), 0, 4);
	bout.writeTo(ESMsock.getOutputStream());
	bout.flush();

	} catch (IOException e) {
	    System.err.println(e.getMessage());

	}
    }
}
