But, I made the client side with pojo class in java like the followings.

import java.io.BufferedInputStream;

import java.io.DataOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.net.Socket;

public class SendClient {

public static void main(String[] args) {

String serverIp = "localhost";

Socket socket = null;

try {

// 서버 연결

socket = new Socket(serverIp, 7777);

System.out.println("서버에 연결되었습니다.");

FileSender fs = new FileSender(socket);

fs.start();

} catch (IOException e) {

e.printStackTrace();

}

}

}

class FileSender extends Thread {

Socket socket;

DataOutputStream dos;

FileInputStream fis;

BufferedInputStream bis;

public FileSender(Socket socket) {

this.socket = socket;

try {

dos = new DataOutputStream(socket.getOutputStream());

} catch (IOException e) {

e.printStackTrace();

}

}

@Override

public void run() {

try {

String fName = "d:/test2/test.jpg";

dos.writeUTF(fName);

File f = new File(fName);

fis = new FileInputStream(f);

bis = new BufferedInputStream(fis);

int len;

int size = 4096;

byte[] data = new byte[size];

while ((len = bis.read(data)) != -1) {

dos.write(data, 0, len);

}

dos.flush();

dos.close();

bis.close();

fis.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

Finally, I got error like the followings.

CRLF not found before max message length: 2048

I think I have to ignore serializer/deserializer for communication between two sides.

网友答案:

Since you don't use Spring Integration IP on the client side you should take care about the end of message manually.

From other side looks like your CustomSerializerDeserializer is an extension of ByteArrayCrLfSerializer, because the message CRLF not found before max message length: is exactly from there.

So, the first: you should increase the maxMessageSize for the CustomSerializerDeserializer and second - you have to supply \r\n bytes in the end of write on the client. Or just use ByteArrayCrLfSerializer.serialize there.