#pragma once #include "Core/Base/RingBuffer.hpp" #include "Socket.h" #include "global.h" #include namespace Psc::asio_socket { #ifndef PSC_ASIO_STREAM_RING_BUFFER #define PSC_ASIO_STREAM_RING_BUFFER StreamRingBuffer_ST #endif #ifndef PSC_ASIO_PACKET_RING_BUFFER #define PSC_ASIO_PACKET_RING_BUFFER RingBuffer_ST #endif using ASIO_StreamRingBuffer = PSC_ASIO_STREAM_RING_BUFFER; using ASIO_PacketRingBuffer = PSC_ASIO_PACKET_RING_BUFFER; inline Socket_FD socket_id(const void *ptr) { return static_cast(reinterpret_cast(ptr)); } inline Sockaddr_In endpoint_to_sockaddr(const asio::ip::tcp::endpoint &endpoint) { return {endpoint.address().to_string(), endpoint.port()}; } inline Sockaddr_In endpoint_to_sockaddr(const asio::ip::udp::endpoint &endpoint) { return {endpoint.address().to_string(), endpoint.port()}; } inline bool would_block(const asio::error_code &ec) { return ec == asio::error::would_block || ec == asio::error::try_again; } } // namespace Psc::asio_socket