...
This commit is contained in:
parent
bd0654a8af
commit
5b50d714f7
@ -168,7 +168,8 @@ concept adc_netsession_c =
|
||||
requires adc_netservice_c<typename SESST::netservice_t>;
|
||||
typename SESST::netsession_ctx_t;
|
||||
|
||||
requires std::constructible_from<SESST, const typename SESST::netsession_ident_t, typename SESST::netservice_t,
|
||||
requires std::constructible_from<SESST, const typename SESST::netsession_ident_t,
|
||||
std::shared_ptr<typename SESST::netservice_t>,
|
||||
typename SESST::netsession_ctx_t>;
|
||||
|
||||
// netsession_ident_t ident() const
|
||||
|
||||
@ -450,23 +450,53 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
auto buff = _streamBuffer.prepare(2880);
|
||||
|
||||
if constexpr (std::derived_from<socket_t,
|
||||
asio::basic_stream_socket<typename socket_t::protocol_type>>) {
|
||||
return asio::async_read(_socket, _streamBuffer, asio::transfer_at_least(1),
|
||||
return asio::async_read(_socket, std::move(buff), asio::transfer_at_least(1),
|
||||
std::move(self));
|
||||
} else if constexpr (std::derived_from<socket_t, asio::basic_datagram_socket<
|
||||
typename socket_t::protocol_type>>) {
|
||||
// datagram, so it should be received at once
|
||||
return _socket.receive(_streamBuffer, std::move(self));
|
||||
return _socket.async_receive(std::move(buff), std::move(self));
|
||||
} else if constexpr (std::derived_from<socket_t, asio::basic_seq_packet_socket<
|
||||
typename socket_t::protocol_type>>) {
|
||||
// datagram, so it should be received at once
|
||||
return _socket.receive(_streamBuffer, *out_flags, std::move(self));
|
||||
return _socket.async_receive(std::move(buff), *out_flags, std::move(self));
|
||||
} else {
|
||||
static_assert(false, "UNKNOWN ASIO-LIBRARY SOCKET TYPE!!!");
|
||||
}
|
||||
// if constexpr (std::derived_from<socket_t,
|
||||
// asio::basic_stream_socket<typename socket_t::protocol_type>>)
|
||||
// {
|
||||
// return asio::async_read(_socket, _streamBuffer, asio::transfer_at_least(1),
|
||||
// std::move(self));
|
||||
// } else if constexpr (std::derived_from<socket_t, asio::basic_datagram_socket<
|
||||
// typename socket_t::protocol_type>>) {
|
||||
// // datagram, so it should be received at once
|
||||
// return _socket.async_receive(_streamBuffer, std::move(self));
|
||||
// } else if constexpr (std::derived_from<socket_t, asio::basic_seq_packet_socket<
|
||||
// typename socket_t::protocol_type>>) {
|
||||
// // datagram, so it should be received at once
|
||||
// return _socket.async_receive(_streamBuffer, *out_flags, std::move(self));
|
||||
// } else {
|
||||
// static_assert(false, "UNKNOWN ASIO-LIBRARY SOCKET TYPE!!!");
|
||||
// }
|
||||
}
|
||||
|
||||
// zero-length message for SEQ_PACK sockets is EOF
|
||||
if constexpr (std::derived_from<socket_t,
|
||||
asio::basic_seq_packet_socket<typename socket_t::protocol_type>>) {
|
||||
if (!nbytes) {
|
||||
timer->cancel();
|
||||
self.complete(std::make_error_code(std::errc::connection_aborted), std::move(msg));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_streamBuffer.commit(nbytes);
|
||||
|
||||
// if (!nbytes) {
|
||||
// do_read = true;
|
||||
// asio::post(std::move(self)); // initiate consequence socket's read operation
|
||||
|
||||
@ -18,9 +18,10 @@ public:
|
||||
typedef SessionContextT netsession_ctx_t;
|
||||
|
||||
typedef AdcNetServiceASIOBase<TRANSPORT_PROTOT, SESSION_PROTOT, RMSGT> netservice_t;
|
||||
typedef std::shared_ptr<netservice_t> netservice_sptr_t;
|
||||
|
||||
template <traits::adc_input_char_range R, traits::adc_is_callable RECV_MSG_TOKENT>
|
||||
AdcGenericNetSessionASIO(const R& id, netservice_t netservice, netsession_ctx_t&& context)
|
||||
template <traits::adc_input_char_range R>
|
||||
AdcGenericNetSessionASIO(const R& id, netservice_sptr_t netservice, netsession_ctx_t&& context)
|
||||
: _ident(), _netservice(std::move(netservice)), _sessionContext(std::forward<netsession_ctx_t>(context))
|
||||
{
|
||||
if constexpr (std::is_array_v<R>) {
|
||||
@ -30,7 +31,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
AdcGenericNetSessionASIO(netservice_t netservice, netsession_ctx_t&& context)
|
||||
AdcGenericNetSessionASIO(netservice_sptr_t netservice, netsession_ctx_t&& context)
|
||||
: AdcGenericNetSessionASIO(
|
||||
std::derived_from<TRANSPORT_PROTOT, asio::ip::tcp> ? "ASIO TCP SESSION"
|
||||
: std::derived_from<TRANSPORT_PROTOT, asio::ip::udp> ? "ASIO UDP SESSION"
|
||||
@ -76,7 +77,7 @@ public:
|
||||
protected:
|
||||
netsession_ident_t _ident;
|
||||
|
||||
std::shared_ptr<netservice_t> _netservice;
|
||||
netservice_sptr_t _netservice;
|
||||
|
||||
netsession_ctx_t _sessionContext;
|
||||
|
||||
|
||||
@ -21,16 +21,20 @@ void receive(T srv)
|
||||
|
||||
int main()
|
||||
{
|
||||
asio::ip::tcp::endpoint ept_s(asio::ip::tcp::v4(), 9999);
|
||||
asio::ip::tcp::endpoint ept_c(asio::ip::make_address_v4("0.0.0.0"), 9999);
|
||||
// asio::ip::tcp::endpoint ept_c(asio::ip::address_v4::any(), 9999);
|
||||
// using tr_p_t = asio ::ip::tcp;
|
||||
// using tr_p_t = asio::local::stream_protocol;
|
||||
using tr_p_t = asio::local::seq_packet_protocol;
|
||||
|
||||
// std::cout << "ADDR: " << ept_s << "\n";
|
||||
tr_p_t::endpoint ept_c(std::string("/tmp/AAA").insert(0, 1, '\0'));
|
||||
// tr_p_t::endpoint ept_c("/tmp/AAA");
|
||||
|
||||
// tr_p_t::endpoint ept_c(asio::ip::make_address_v4("0.0.0.0"), 9999);
|
||||
std::cout << "ADDR: " << ept_c << "\n";
|
||||
|
||||
asio::io_context ctx;
|
||||
|
||||
using srv_t = adc::impl::AdcNetServiceASIOBase<asio::ip::tcp, adc::AdcStopSeqSessionProto<>>;
|
||||
// using srv_t = adc::impl::AdcNetServiceASIOBase<tr_p_t, adc::AdcStopSeqSessionProto<>>;
|
||||
using srv_t = adc::impl::AdcNetServiceASIOBase<tr_p_t, adc::AdcStopSeqSessionProto<>>;
|
||||
|
||||
typename srv_t::acceptor_t acc(ctx, ept_c);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user