简体   繁体   中英

How to read socket response?

I use Camel + Netty for my socket connection. In camel-context file, I use Netty for my socket connection but I want Netty to behave like this:

Netty must read chars from input stream with size equal to inputstream.available() but Netty blocks the code because it expects \\r\\n or \\r or \\n at the end of inputstream.

How I can configure Netty to reach this functionality? Which options of Netty should I use?

I use textline=true .

Base on your description you are reading a certain amount of chars from a protocol where each message(line) is of equal length. The line of code Use textline = true tell Netty that you will be sending a text line protocol ie a line might be of variable size and terminated by a sequence of characters such as \\r\\n .

Setting this line to false will remove the need for Netty to wait for a EOL terminator. However you will need to implement some form of codec to read your protocol. Your codec is rather simplistic in that it appears all lines will be the same length.

What about adding autoAppendDelimiter=false to the endpoint? Maybe a code example would be very helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM