Libzmq Chapter 2 - Sockets and Patterns: Difference between revisions

From 탱이의 잡동사니
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:


== The Socket API ==
== The Socket API ==
정말 솔직하게 이야기하자면, ZeroMQ 는 일종의 switch-and-bait 방식으로 동작한다. ZeroMQ는 메시지 프로세싱과 관련한 내용을 숨기고 Socket-based API 를 제공하기때문에 큰 이점을 준다.
Socket 은 네트워크 프로그래밍에서의 사실상의 표준(De facto standard)이다. ZeroMQ 를 더욱 더 돋보이게 만드는 점은 어떤 특별한 컨셉을 적용하는 것이 아닌 일반적인 소켓을 사용한다는 점이다.
먹기 좋은 음식처럼, ZeroMQ 역시 받아들이기 쉽다. ZeroMQ 의 소켓의 사용은 BSD 소켓과 같이 크게 4가지 부분으로 나뉜다.
* Creating and destroying sockets. 소켓을 생성하고 종료한다. (zmq_socket(), zmq_close()).
* Configuring sockets by setting options on them and checking them if necessary. 필요할 경우, 소켓의 속성을 확인하고 설정한다. (zmq_setsockopt(), zmq_getsockopt())
* Plugging sockets into the network topology by creating ZeroMQ connections to and from them. 소켓을 네트워크와 연결한다. (zmq_bind(), zmq_connect())
* Using the sockets to carry data by writing and receiving messages on them. 소켓을 이용하여 메시지를 송신/수신 한다. (zmq_msg_send(), zmq_msg_recv())


== See also ==
== See also ==

Revision as of 00:05, 4 August 2016

챕터 1에서 간단한 ZeroMQ 의 기본 패턴들을 살펴보았다(request-reply, pub-sub, pipeline). 이번 챕터에서는 실제 프로그램에서 이를 어떻게 응용하는지를 살펴보도록 하자.

다음을 살펴볼 예정이다.

  • ZeroMQ 소켓의 생성과 사용
  • 소켓을 이용한 Messsage send/receive
  • ZeroMQ 비동기 I/O 를 이용한 Application 작성
  • 단일 thread 에서 다중 소켓 사용
  • fatal/nonfatal error 관리
  • Interrupt signal(ctrl+c) 관리
  • ZeroMQ 종료 방법
  • ZeroMQ 어플리케이션 메모리 누수 탐지
  • Multipart 메시지 send/receive
  • 네트워크 메시지 forward.
  • 간단한 Message queuing broker 작성법
  • ZeroMQ를 이용한 멀티 쓰레드 프로그램 작성법
  • ZeroMQ 를 이용한 쓰레드 signal 전송
  • ZeroMQ 를 이용한 네트워크 노드 조정
  • pub-sub 에서의 message envelope
  • 메모리 오버플로우를 막기 위한 HWM(high-water mark) 사용법.

The Socket API

정말 솔직하게 이야기하자면, ZeroMQ 는 일종의 switch-and-bait 방식으로 동작한다. ZeroMQ는 메시지 프로세싱과 관련한 내용을 숨기고 Socket-based API 를 제공하기때문에 큰 이점을 준다.

Socket 은 네트워크 프로그래밍에서의 사실상의 표준(De facto standard)이다. ZeroMQ 를 더욱 더 돋보이게 만드는 점은 어떤 특별한 컨셉을 적용하는 것이 아닌 일반적인 소켓을 사용한다는 점이다.

먹기 좋은 음식처럼, ZeroMQ 역시 받아들이기 쉽다. ZeroMQ 의 소켓의 사용은 BSD 소켓과 같이 크게 4가지 부분으로 나뉜다.

  • Creating and destroying sockets. 소켓을 생성하고 종료한다. (zmq_socket(), zmq_close()).
  • Configuring sockets by setting options on them and checking them if necessary. 필요할 경우, 소켓의 속성을 확인하고 설정한다. (zmq_setsockopt(), zmq_getsockopt())
  • Plugging sockets into the network topology by creating ZeroMQ connections to and from them. 소켓을 네트워크와 연결한다. (zmq_bind(), zmq_connect())
  • Using the sockets to carry data by writing and receiving messages on them. 소켓을 이용하여 메시지를 송신/수신 한다. (zmq_msg_send(), zmq_msg_recv())

See also