package nfs;
 
import java.net.DatagramPacket;
 
public class RemoteOutputStream extends RemoteStream{
 
	public RemoteOutputStream(String serverName) {
		super(serverName);
	}
 
 
	public boolean write(byte[] buff) {
		// TODO Auto-generated method stub
		UDPServerComm comm = new UDPServerComm(serverName, NfsServer.port);
		DatagramPacket dp = RemotePacket.RemotePacket("WRITE",handle,new String(buff));
		// packet received: contains the String remote handle
		DatagramPacket answer = comm.call(dp);
		if(answer == null) 
			return false; // error receiving
		String error = new String(answer.getData(),0,answer.getLength());
		if(error.startsWith("ERROR"))
			return false; 
		else
			return true;
	}	
}