@@ -293,6 +293,10 @@ io_service::io_service() : stopping_(false), thread_started_(false), interrupter
293293 ares_outstanding_work_ = 0 ;
294294#endif
295295 ipsv_state_ = 0 ;
296+
297+ this ->xdec_len_ = [](io_service *service, void *ptr, int len) {
298+ return service->builtin_decode_frame_length (ptr, len);
299+ };
296300}
297301
298302io_service::~io_service () { stop_service (); }
@@ -383,6 +387,9 @@ void io_service::set_option(int option, ...)
383387 case MASIO_OPT_IO_EVENT_CALLBACK:
384388 this ->on_event_ = std::move (*va_arg (ap, io_event_callback_t *));
385389 break ;
390+ case MASIO_OPT_DECODE_FRAME_LENGTH_FUNCTION:
391+ this ->xdec_len_ = std::move (*va_arg (ap, decode_frame_length_fn_t *));
392+ break ;
386393 }
387394
388395 va_end (ap);
@@ -1174,7 +1181,7 @@ bool io_service::do_read(transport_ptr transport)
11741181#endif
11751182 if (transport->receiving_pdu_elen_ == -1 )
11761183 { // decode length
1177- int length = decode_frame_length ( transport->buffer_ , transport->offset_ + n);
1184+ int length = this -> xdec_len_ ( this , transport->buffer_ , transport->offset_ + n);
11781185 if (length > 0 )
11791186 {
11801187 transport->receiving_pdu_elen_ = length;
@@ -1556,7 +1563,7 @@ void io_service::handle_ares_work_finish(channel *)
15561563}
15571564#endif
15581565
1559- int io_service::decode_frame_length (void *ud, int n)
1566+ int io_service::builtin_decode_frame_length (void *ud, int n)
15601567{
15611568 if (options_.lfib .length_field_offset >= 0 )
15621569 {
0 commit comments