Strumenti Utente

Strumenti Sito


lpr-b-2007-2008:remoteoutputstream
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;
	}	
}
lpr-b-2007-2008/remoteoutputstream.txt · Ultima modifica: 19/09/2008 alle 14:08 (11 anni fa) (modifica esterna)