2013-09-04 4 views
2

OneConnector 예제를 기반으로 간단한 임베디드 부두 프로젝트를 만들었습니다.부두가 시동 할 때 왜 많은 연결을 설정합니까?

예를 시작할 때 예상 한 감상 상태에서 하나의 TCP 연결이 표시됩니다. 또한 확립 된 상태에서 상당수의 TCP 연결이 있습니다.

왜 그곳에 있습니까? 왜 그렇게 많이 사용되고 무엇을 사용합니까?

나는 다음과 같은 연결 참조 TCPView에서

: 그것은 이렇게되면 기본적으로 source code에서

java.exe:14536  TCP  my-pc:8080  my-pc.tfs.attix5.com:0 LISTENING  
java.exe:14536  TCP  my-pc:56791  localhost:56792   ESTABLISHED  
java.exe:14536  TCP  my-pc:56792  localhost:56791   ESTABLISHED  
java.exe:14536  TCP  my-pc:56793  localhost:56794   ESTABLISHED  
java.exe:14536  TCP  my-pc:56794  localhost:56793   ESTABLISHED  
java.exe:14536  TCP  my-pc:56795  localhost:56796   ESTABLISHED  
java.exe:14536  TCP  my-pc:56796  localhost:56795   ESTABLISHED  
java.exe:14536  TCP  my-pc:56797  localhost:56798   ESTABLISHED  
java.exe:14536  TCP  my-pc:56798  localhost:56797   ESTABLISHED  
java.exe:14536  TCP  my-pc:56799  localhost:56800   ESTABLISHED  
java.exe:14536  TCP  my-pc:56800  localhost:56799   ESTABLISHED  
java.exe:14536  TCP  my-pc:56801  localhost:56802   ESTABLISHED  
java.exe:14536  TCP  my-pc:56802  localhost:56801   ESTABLISHED  
java.exe:14536  TCP  my-pc:56803  localhost:56804   ESTABLISHED  
java.exe:14536  TCP  my-pc:56804  localhost:56803   ESTABLISHED  
java.exe:14536  TCP  my-pc:56805  localhost:56806   ESTABLISHED  
java.exe:14536  TCP  my-pc:56806  localhost:56805   ESTABLISHED  
+0

8 개의 CPU가 있습니까? – ZhongYu

+0

예. 있습니다. 스레드 당 하나의 연결 쌍을 생각하고 있습니까? – Christo

+0

8 개의 셀렉터가 생성 될 수 있습니다. 각 선택기에 대해 wakeup()을 위해 소켓이 설정됩니다. – ZhongYu

답변

0

을 ...

_manager = new ServerConnectorManager(
         getExecutor(), 
         getScheduler(), 
         selectors>0? 
         selectors: 
         Math.max(1,Math.min(4,Runtime.getRuntime().availableProcessors()/2) 
         )); 
addBean(_manager, true); 

는 그래서이 수를 기반으로, 증명 프로세서는 기본적으로 시작된 선택기의 수와 관련이 있습니다.