发送多个文件时出现Java客户端服务器问题

发送多个文件时出现Java客户端服务器问题,java,file-io,client-server,Java,File Io,Client Server,我重写了一些代码来实现下面的两个答案,low,瞧,我让它发送了一个映像,但现在我只需要它继续发送,但是服务器在发送了一个映像后就完成了 客户(修订版): } 输出: Welcome to DrJava. Working directory is C:\Documents and Settings\Dapper Dan\Desktop > run ServerQueue.Client Connected to : localhost transfer: Sunset.jpg 711

我重写了一些代码来实现下面的两个答案,low,瞧,我让它发送了一个映像,但现在我只需要它继续发送,但是服务器在发送了一个映像后就完成了

客户(修订版):

}

输出:

    Welcome to DrJava.  Working directory is C:\Documents and Settings\Dapper Dan\Desktop
> run ServerQueue.Client
Connected to : localhost
transfer: Sunset.jpg
71189
file done: 0
transfer: Water lilies.jpg
83794
FileIO Error: java.net.SocketException: Socket is closed
Connected to : localhost
transfer: Sunset.jpg
71189
> 
这是客户端的输出,传输的唯一图像是Sunset.jpg,如file done语句所示


你知道是什么原因造成的吗?

你的大小计数器是否真的用你读取的字节数进行了更新? 难道不是:

while (counter < length ){
    num = bis.read(receivedData);
    bos.write(receivedData,0,num);
    counter += num;
}
while(计数器
在客户端,将套接字(和相关流)创建移动到numFiles迭代器循环下

for (int itor = 0; itor < numFiles; itor++) {
//socket = new Socket(...
//socket's outputstream = ....
for(int-itor=0;itor

在服务器端,将socket.accept调用及其下的所有逻辑移动到while(true)循环下。

在服务器上,错误是:在java.io.BufferedOutputStream.write(未知源)的ServerQueue.ImageServer.main的java.lang.System.arraycopy(本机方法)处生成1 28522 Filename=Blue hills.jpgjava.lang.ArrayIndexOutOfBoundsExceptionsun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)sun.reflect.NativeMethodAccessorImpl.invoke(未知源)sun.reflect.DelegatingMethodAccessorImpl.invoke(未知源)java.lang.reflect.Method.invoke(未知源)edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)在客户端上,它是:传输:Blue hills.jpg 2852java.lang.ArrayIndexOutOfBoundsException连接到:localhost传输:Blue hills.jpg 2852java.lang.ArrayIndexOutOfBoundsException连接到:localhost传输:Blue hills.jpg 2852java.lang.ArrayIndexOutOfBoundsException连接到:localhost传输:Blue hills.jpg 28522再见,亲爱的,非常感谢!
while (counter < length ){
    num = bis.read(receivedData);
    bos.write(receivedData,0,num);
    counter += num;
}
for (int itor = 0; itor < numFiles; itor++) {
//socket = new Socket(...
//socket's outputstream = ....