Java 响应后如何关闭spring集成tcp连接
我正在编写一个带有0字节终止符的tcp服务器。 安装程序正在双向运行,但服务器在发送响应后不会关闭连接: 设置:Java 响应后如何关闭spring集成tcp连接,java,tcp,spring-integration,Java,Tcp,Spring Integration,我正在编写一个带有0字节终止符的tcp服务器。 安装程序正在双向运行,但服务器在发送响应后不会关闭连接: 设置: <int-ip:tcp-connection-factory id="MyServerConnectionFactory" type="server" port="8083" serializer="MyConnect
<int-ip:tcp-connection-factory id="MyServerConnectionFactory"
type="server"
port="8083"
serializer="MyConnectionSerializeDeserialize"
deserializer="MyConnectionSerializeDeserialize"
/>
<bean id="MyConnectionSerializeDeserialize" class="org.springframework.integration.ip.tcp.serializer.ByteArraySingleTerminatorSerializer">
<constructor-arg type="byte" value="0" />
<property name="maxMessageSize" value="100000"/>
</bean>
<int-ip:tcp-inbound-gateway id="MyGateway"
connection-factory="MyServerConnectionFactory"
request-channel="MyIncomingServerChannel"
error-channel="errorChannel"/>
<int:channel id="MyIncomingServerChannel"/>
<int:service-activator input-channel="MyIncomingServerChannel"
ref="MyService"
method="process"/>
<bean id="MyService"
class="mypackage.MyService"/>
在返回响应后,我如何告诉框架关闭连接
Thanx客户端通常负责在收到响应后关闭套接字,但如果在连接工厂上设置
single use=“true”
,则在发送响应后,套接字将关闭(通常为-FIN)。是的,但客户端是php,在收到0x00字符后不会关闭连接,而它使用的一些socket_recv()函数缺少配置。。它只是永远的等待。。
public byte[] process(byte[] input) {
ByteArrayInputStream stream = new ByteArrayInputStream(input);
// process the stream
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(outstream);
pw.print("Ok");
pw.flush();
return outstream.toByteArray();
}