Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 响应后如何关闭spring集成tcp连接_Java_Tcp_Spring Integration - Fatal编程技术网

Java 响应后如何关闭spring集成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

我正在编写一个带有0字节终止符的tcp服务器。 安装程序正在双向运行,但服务器在发送响应后不会关闭连接:

设置:

<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();
}