2012-02-10 4 views
1

내가 포트 30003. 수신 작은 프로그램을 가지고 그것은 다음과 같이 바이트 스트림의 데이터를 처리하는 서버 클래스입니다 완성. 여기에 같은 일을 달성하기위한 것입니다 뭔가 내 TCP-상황이다 : 나는 봄의 통합 접근 방식을 사용하여 프로그램을 시작하면소켓 및 봄 통합

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:ip="http://www.springframework.org/schema/integration/ip" 
    xsi:schemaLocation="http://www.springframework.org/schema/integration 
http://www.springframework.org/schema/integration/spring-integration-2.1.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/integration/ip 
http://www.springframework.org/schema/integration/ip/spring-integration-ip-2.0.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd"> 


<context:component-scan base-package="com.atlaschase.falcon.integration"></context:component-scan> 

<int:channel id="heathrowChannel"></int:channel> 

<ip:tcp-connection-factory id="heathrowConnectionFactory" type="server" host="127.0.0.1" port="30003"/> 

<ip:tcp-inbound-channel-adapter id="heathrowInboundAdapter" channel="heathrowChannel" connection-factory="heathrowConnectionFactory"/> 

<int:service-activator id="adsbHandler" input-channel="heathrowChannel" ref="sbsListener"/> 

</beans> 

, 나는 다음과 같은 스택 추적을 얻을 - 소켓 주소가 이미 있음을 말해 사용.

SEVERE: Error on ServerSocket 
java.net.BindException: Address already in use: JVM_Bind 
    at java.net.PlainSocketImpl.socketBind(Native Method) 
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383) 
    at java.net.ServerSocket.bind(ServerSocket.java:328) 
    at java.net.ServerSocket.<init>(ServerSocket.java:194) 
    at java.net.ServerSocket.<init>(ServerSocket.java:150) 
    at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:163) 
    at org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory.run(TcpNetServerConnectionFactory.java:61) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 

왜 내 표준 소켓 프로그램이 제대로 작동하는지 이해하지 못합니다. 왜 통합 접근 방식이 넘어 지나요? 내 컴퓨터에는 30003 포트에서 데이터를 사용할 수있는 소프트웨어가 있습니다.

도와 주시면 감사하겠습니다.

감사합니다.

+0

당신이 봄에 새로운 구현을 시작하기 전에 포트 30003에서 수신 프로그램을 중지 했을? –

+0

예. 내가 듣고 자하는 데이터를 제공하는 30003에서 실행되는 ** 응용 프로그램 **이 있습니다. 소켓 접근 방식은 실행중인 응용 프로그램과 잘 작동하지만이 SI는 오류를 생성합니다. – totalcruise

+3

포트에 대한 수신 대기 *는 서버 소켓 열기를 의미하며 같은 포트를 여는 응용 프로그램이 두 개 이상있을 수 없습니다. 스프링 구성은 포트 30003에서 * ServerSocket *을 열려고하는데, 따라서받는 예외는 이미 사용중인 주소입니다. –

답변

1

이것은 서버와 클라이언트 사이의 혼란을 해결하여 해결됩니다. 응용 프로그램이 이미 해당 포트 번호에 바인딩되어 있으므로 서버 소켓을 생성 할 수 없습니다. 포트에 '경청'으로

'30003'나 '클라이언트'형태의 ConnectionFactory를 생성했다 :

<ip:tcp-connection-factory id="heathrowConnectionFactory" type="server" host="127.0.0.1" port="30003"/>