入力ストリームをソケットから byteArray に読み込みたいのですが、次のエラーが発生します。
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
inputStream の読み取りが完了するまでソケットを閉じないため、理由はわかりません
try {
in = connexion.getSocket().getInputStream();
out = connexion.getSocket().getOutputStream();
byte[] buffer= new byte[2048] ;
ByteArrayOutputStream baos= new ByteArrayOutputStream();
int read = 0;
while((read = in.read(buffer)) > 0) // exception thrown here
{
baos.write(buffer, 0, read);
}
reception = baos.toByteArray();
}
catch (IOException e) {
e.printStackTrace();
}
finally{
try{
in.close();
out.close();
connexion.getSocket().close();
}
catch(IOException ioException){
ioException.printStackTrace();
}
}
サーバ側:
public static void main(String[] args) throws Exception {
ServerSocket s = new ServerSocket(port,2);
Socket soc ;
while(true){
soc = s.accept(); } }
どうもありがとうございました