나는 자바의 소켓을 통해 바이트 배열을 전송하는 애플리케이션을 작성하고있다.소켓에서 바이트 배열을 읽을 수 없다
다음 클라이언트 단에서 바이트 배열의 생성은 : 서버 측
String vote = br.readLine();
// the data that i now encrypt using RSA
PublicKey pubKey = readKeyFromFilepublic("alicepublic.txt");
Cipher cvote = Cipher.getInstance("RSA");
cvote.init(Cipher.ENCRYPT_MODE, pubKey);
byte[] voted = cvote.doFinal(vote.getBytes());
System.out.println(voted);
out.println(voted.length);
dos.write(voted,0,voted.length); // here i am sending the array to the server
i는 I가 파일에 기록하여 암호화 및 암호 해독 처리를 체크인
String clen = in.readLine(); // read the length
byte[] array = new byte[Integer.parseInt(clen)]; // create the array of that length
dist.readFully(array); // read the array
// i am unable to read the array here at all !
PrivateKey priKey = readKeyFromFileprivate("aliceprivate.txt");
Cipher vote = Cipher.getInstance("RSA");
vote.init(Cipher.DECRYPT_MODE, priKey);
byte[] voteData = vote.doFinal(array);
System.out.println(voteData);
// finally print the decrypted array
쓰기 제대로 작동합니다.
저는 양쪽에서 DataInput 및 DataOutput 스트림을 사용하고 있습니다.
내 코드가 잘못되었다는 것을 알려주실 수 있습니까?
예외는 무엇입니까? 오류? 스택 트레이스? – beny23
예외는 발생하지 않고 소켓에서 바이트 배열을 읽으려고 계속 대기합니다. –