1 / 21

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 Library Queue Application

  6. MessageBlock

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

  8. Block에서 읽어오기 memcpy(buffer, block.rd_ptr(), block.length()); block.rd_ptr(block.length());

  9. Block에 쓰기 block.copy(buffer, write_length);

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

  11. Queue에서 꺼냈을 때(PopMessage) Command Block Payload Block

  12. Command Block

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

  14. Payload Block

  15. Queue에서 꺼냈을 때(PopAllMessage) Command Block Payload Block

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

  17. 설정관련 함수들 NetworkFacade->SetWorkerThreadCount(count); NetworkFacade->SetSendMode(DIRECT_SEND); NetworkFacade->SetReceiveBufferLen(1024*4); NetworkFacade->SetIntervalSendTerm(20);

  18. 동작관련 함수들 NetworkFacade->Connect(ip,port,queue_id); NetworkFacade->SendRequest(streamID,block); NetworkFacade->CloseStream(streamID); NetworkFacade->PopAllMessage(block); NetworkFacade->SuspendAcceptor(port); NetworkFacade->ResumeAcceptor(port); NetworkFacade->Dump();

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

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

  21. Q&A

More Related