프로그래밍/c++ - boost::asio
-
boost::asio::buffer_cast는 deperecated프로그래밍/c++ - boost::asio 2020. 7. 31. 16:18
https://www.boost.org/doc/libs/1_73_0/doc/html/boost_asio/reference/buffer_cast.html buffer_cast - 1.73.0 (Deprecated: Use the data() member function.) The boost::asio::buffer_cast function is used to obtain a pointer to the underlying memory region associated with a buffer. Cast a non-modifiable buffer to a specified pointer to POD type. template< typename Po www.boost.org 확인 결과 boost 1.66.0 부터..
-
boost asio, Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately.프로그래밍/c++ - boost::asio 2020. 5. 27. 01:26
1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example: 1>- add -D_WIN32_WINNT=0x0601 to the compiler command line; or 1>- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions. 1>Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target). 위는 boost asio를 포함하여 빌드하면 발생하는 "_WIN32_WINNT 또는 _WIN32_WINDOWS를 정의해주세요" 메세지. 다음 링크에서 윈도우에 해당하는 전처리 매크로에 정의하면 해당 메세지는 발생하지 않는다. https:..
-
boost/asio deprecated 1.69.0프로그래밍/c++ - boost::asio 2019. 3. 11. 04:44
boost::asio가 c++ 표준에 들어가게 되서 그런지 변경 사항들이 많다.호환성을 위해 더이상 더이상 사용되지 않는 코드들이 여전히 남아있지만,전처리기에 BOOST_ASIO_NO_DEPRECATED를 지정하면 더이상 사용되지 않는 코드들이 비활성화 된다. io_service가 io_context로 이름 변경io_context::dispatch가 dispatch 로 대체 됨io_context::post가 post 로 대체 됨io_context::strand::wrap이 bind_execuator 로 대체 됨io_context::get_io_context(), io_context::get_io_service()가 context() 함수로 이름 변경.io_context::strand::get_io_con..
-
boost::asio dynamic buffer프로그래밍/c++ - boost::asio 2018. 5. 1. 14:06
asio에 dynamic_buffer라는 것이 추가되었다.asio::streambuf와 비슷하지만, 기존의 stl 컨테이너(std::vector, std::string 등)을 래퍼런스로 받아 조작하는 어뎁터 클래스이다.사용 방식은 다음과 같다. #include #include int main(){ using DynamicBuffer = boost::asio::dynamic_vector_buffer; std::vector buffer; DynamicBuffer dynamicBuffer = boost::asio::dynamic_buffer(buffer); return 0;} api도 기존의 asio::streambuf와 흡사하며 메모리를 공간을 확보, 반환해주는 prepare 함수의 경우 다음과 같이 구현되..
-
boost 의존성 없이 사용하기. asio standalone프로그래밍/c++ - boost::asio 2018. 4. 7. 19:20
asio를 boost 의존성 없이 단독으로 사용할 수 있다. 0. https://think-async.com/Asio/Download에서 asio를 다운 받는다.1. asio 소스를 프로젝트 내에 포함한다.2. 전처리기를 정의한다. #define ASIO_STANDALONE 그러면 boost가 아예 없어도 asio를 사용할 수 있다. ASIO_STANDALONE이 정의가 없으면 boost 의존성이 있으므로 주의!! boost::system::error_code -> asio::error_code 등으로 바뀌는 것들도 있다.
-
asio io_service의 dispatch가 post와 다른 점과 적절한 사용처프로그래밍/c++ - boost::asio 2016. 5. 1. 02:45
post()와 dispatch()의 차이 post()는 단순히 핸들러를 io_service 내부에 추가, dispatch()는 호출될 때 호출 스레드 io_service:: run(), poll() 등을 통해 실행되었다면 dispatch한 핸들러를 io_service 내부에 추가하지 않고, 즉시 실행. 그렇다면 dispatch가 호출되는 게 io_service를 통해서가 아니라면 어떨까? post처럼 io_service 내부에 추가된다. 코드로 보자면..12345678910111213141516171819202122int main(){ using namespace boost::asio; io_service proactor; boost::thread_group threads; for(int i = 3; i..
-
코루틴(coroutine) 사용 중 주의해야 할 부분?프로그래밍/c++ - boost::asio 2015. 12. 26. 03:39
얼마 전부터, 코루틴을 사용한 비동기 프로그래밍에 관심이 있었다.그래서 asio example로 나와있는 코드(spawn 예제)를 보면서 다음과 같은 코드를 짜봤는데, 이런 상황에 대한 문제가 있을 거 같더라. 1234567891011121314151617181920212223 void listen(boost::asio::ip::tcp::endpoint endpoint, bool reuse_address = true) { boost::asio::spawn(strand_, [this, endpoint, reuse_address](boost::asio::yield_context yield) { tcp::acceptor acceptor{ service_, endpoint, reuse_address }; acc..