在客户机上,我使用Arrays.CopyofRange()从一个FileEvent对象块缓冲区:
byte[] data = outputStream.toByteArray();
for (int i = 0; i <= data.length; i += incommingData.length) {
byte[] forSent = new byte[0x3ff];
forSent = Arrays.copyOfRange(data, i, i + 1023);
DatagramPacket sendPacket = new Dat
我有一个项目,要求使用UDP协议传输文件,但仍然要保证TCP协议的特性。这意味着我们有UDP的速度,文件不会丢失。
我已经有了:
服务器:
public class UDPServer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int port = 6788;