protected long encodeBinary(OutputStream objOut, RPCObject rpcObj) throws IOException {
		long byteSent = 0L;
		RPCBinaryObject rcpbinary = (RPCBinaryObject)rpcObj;
		Object val = rpcObj.getValue();
		File f = null;
		byte[] data = null;
		if(val instanceof File){
			f = (File) val;
		}else if(val instanceof String){
			f = new File((String) val);
		}else{
			 data = (byte[])val;
		}
		
		if(f!=null){
			String fname = rcpbinary.getName()==null?f.getCanonicalPath().replaceAll("\\", "/"):rcpbinary.getName();
			byte[] fnames = fname.getBytes();
			writeInt(objOut,fnames.length);
			byteSent += 4L;
			objOut.write(fnames);	
			byteSent += fnames.length;
			long flength = f.length();
			writeInt(objOut,(int)flength);
			FileInputStream fin = null;
			try{
				fin = new FileInputStream(f);
				int sent = 0;
				int read = 0;				
				while((read=fin.read(BINARY_BUFFER))!=-1){
					objOut.write(BINARY_BUFFER, 0, read);
					sent += read;					
				}
				if(sent!=f.length()){
					//Warnning message here;
				}
				byteSent += sent;
			}finally{
				if(fin!=null) fin.close();
			}			
		}else{
			String fname = rcpbinary.getName()==null?"":rcpbinary.getName();
			byte[] fnames = fname.getBytes();
			writeInt(objOut,fnames.length);			
			objOut.write(fnames);
			byteSent += 4L;
			if(data==null){
				writeLong(objOut, RPC_OBJECT_VAL_NIL);
			}else{
				writeLong(objOut, data.length);
				objOut.write(data);		
				byteSent += data.length;
			}
		}
		return byteSent;
	}