mule配置tcp

配置文件:
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.1"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:file="http://www.mulesource.org/schema/mule/file/2.1"
       xmlns:tcp="http://www.mulesource.org/schema/mule/tcp/2.1"
       xmlns:xm="http://www.mulesource.org/schema/mule/xml/2.1"
       xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.1"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://www.mulesource.org/schema/mule/core/2.1 http://www.mulesource.org/schema/mule/core/2.1/mule.xsd
       http://www.mulesource.org/schema/mule/file/2.1 http://www.mulesource.org/schema/mule/file/2.1/mule-file.xsd
       http://www.mulesource.org/schema/mule/tcp/2.1 http://www.mulesource.org/schema/mule/tcp/2.1/mule-tcp.xsd
       http://www.mulesource.org/schema/mule/xml/2.1 http://www.mulesource.org/schema/mule/xml/2.1/mule-xml.xsd
       http://www.mulesource.org/schema/mule/stdio/2.1 http://www.mulesource.org/schema/mule/stdio/2.1/mule-stdio.xsd">
     <tcp:connector name="TcpConnector" 
             keepAlive="true" receiveBufferSize="2048" sendBufferSize="2048"
            receiveBacklog="500" serverSoTimeout="3000" 
            keepSendSocketOpen="true"  validateConnections="true">
            <tcp:direct-protocol payloadOnly="true"/>
    </tcp:connector>
     <tcp:endpoint connector-ref="TcpConnector" name="Endpoint" host="127.0.0.1" port="5200" synchronous="true"/>
    <model name="tcpModel">
        <service name="tcpService">
            <inbound>
				<tcp:inbound-endpoint name="inboundEndpoint"  connector-ref="TcpConnector" host="127.0.0.1" port="5200" />
            </inbound>
            <outbound>
                <pass-through-router>
                    <file:outbound-endpoint path="./out" outputPattern="EMAIL-[DATE].txt"/>
                </pass-through-router>
            </outbound>
        </service>
    </model>
</mule>

客户端访问:
package org;

import java.net.*;
import java.io.*;

public class Client {

	public static void main(String[] args) throws Exception {
		Socket server = new Socket(InetAddress.getByName("127.0.0.1"), 5200);
		BufferedReader in = new BufferedReader(new InputStreamReader(server
				.getInputStream()));
		PrintWriter out = new PrintWriter(server.getOutputStream());
		String str = "aaa";
		out.println(str);
		out.flush();
		server.close();
	}
}

你可能感兴趣的:(java,.net,socket)