1 / 17

OpenSource Network Library HalfNetwork

OpenSource Network Library HalfNetwork. 임영기 javawork93@gmail.com. HalfNetwork 란. ACE 를 이용하여 만든 C++ 네트워크 라이브러리 Half-Sync / Half- Async (POSA2) 패턴의 구현물. ACE. Open source object-oriented framework Socket / Thread / Lock / Buffer 여러 패턴의 집약체 Wrapper Façade Adaptor Composite. ACE 컴파일.

Download Presentation

OpenSource Network Library HalfNetwork

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenSourceNetwork LibraryHalfNetwork 임영기 javawork93@gmail.com

  2. HalfNetwork란 • ACE를 이용하여 만든 C++ 네트워크 라이브러리 • Half-Sync / Half-Async(POSA2) 패턴의구현물

  3. ACE • Open source object-oriented framework • Socket / Thread / Lock / Buffer • 여러 패턴의 집약체 • Wrapper Façade • Adaptor • Composite

  4. ACE 컴파일 • $ACE_ROOT : ACE_wrappers폴더 • $ACE_ROOT/ace/config.h생성 • #define ACE_HAS_STANDARD_CPP_LIBRARY 1 • #define ACE_USES_WCHAR 1 • #include "ace/config-win32.h“ • $ACE_ROOT/ace/ace_Static.sln 컴파일 • aces.lib acesd.lib • ACE_AS_STATIC_LIBS 선언

  5. Half-Sync / Half-Async Pattern

  6. Message_Block의기능 #1 버퍼 관리 ReadPtr WritePtr Size Size = block.size(); // Size Length = block.length(); // WritePtr – ReadPtr Space = block.space(); // Size – WritePtr

  7. Block에서 읽어오기 memcpy(buffer, block->rd_ptr(), read_length); block->rd_ptr(read_length);

  8. Block에 쓰기 block->copy(buffer, write_length);

  9. Message_Block의 기능 #2Chained Message_Block Block Next • Composite 패턴 • Head만 넘기면 됨 • 데이터 복사를 줄여준다

  10. Queue에서 꺼냈을 때 Command Block Payload Block

  11. Command Block

  12. Payload Block

  13. 초기화 코드 NetworkFacade->Create(newProactorFactory); NetworkFacade->AddAcceptor( port, queue_id); NetworkFacade->Open();

  14. 패킷 처리 코드 ACE_Message_Block* commandBlock = NULL; NetworkFacade->PopMessage(queue_id, &commandBlock, -1); ... switch(postee.command) { caseMessageHeader::ESTABLISH: ... break; caseMessageHeader::READ: ... break; caseMessageHeader::CLOSE: ... break; }

  15. 기타 함수들 NetworkFacade->SetWorkerThreadCount(count); NetworkFacade->Connect(ip,port,queue_id); NetworkFacade->SendRequest(streamID,block); NetworkFacade->CloseStream(streamID); NetworkFacade->PopAllMessage(block); NetworkFacade->SuspendAcceptor(port); NetworkFacade->ResumeAcceptor(port);

  16. Packet Generator Packet Generator YAML 정의 파일 C++ 소스 파일

  17. 참고 • ACE 다운로드 : http://download.dre.vanderbilt.edu/ • HalfNetwork다운로드 : https://sourceforge.net/projects/halfnetwork/ • HalfNetwork한국어 위키: http://halfnetwork.springnote.com/ • Blog: http://javawork.egloos.com/

More Related