public static HandShake readBlockingHandShake(InputStream in) throws IOException{
		boolean inComplete = false;
		HandShake hs = null;
		int size=-1;byte[] buffer = null;int off=0;
		while (!inComplete) {
			if (size == -1) {
				size = in.read();
				buffer = new byte[48 + size];
				off = 0;
				if(size>=100 && size<0){
					throw new RuntimeException("Invalid size "+size);
				}
			} else {
				off += in.read(buffer, off, 48 + size-off);
				if (off == 48 + size) {
					byte [] version = Arrays.copyOfRange(buffer, 0, size);
					byte [] reserved = Arrays.copyOfRange(buffer, size, size + 8);
					byte [] hashInfo = Arrays.copyOfRange(buffer, size + 8,size + 8 + 20);
					byte [] peerID = Arrays.copyOfRange(buffer, size + 8 + 20,size + 8 + 20 + 20);
					hs = new HandShake(peerID,hashInfo,version,reserved);
					inComplete=true;
				}
			}
		}
		return hs;
	}