bool is_cgi(implementation_type& impl) { if (transport_ == detail::transport::pipe) { return is_cgi_; } else // transport_ == detail::transport::socket { boost::system::error_code ec; socklen_t len(static_cast<socklen_t>(local_endpoint(impl,ec).capacity())); int check (getpeername(native(impl), local_endpoint(impl,ec).data(), &len)); return ( check == SOCKET_ERROR && WSAGetLastError() == WSAENOTCONN ) ? false : true; } }
endpoint basic_socket::local_endpoint() { system::error_code e; endpoint ep=local_endpoint(e); if(e) throw system::system_error(e); return ep; }
bool is_cgi(implementation_type& impl) { boost::system::error_code ec; socklen_t len ( static_cast<socklen_t>(local_endpoint(impl,ec).capacity()) ); int check ( getpeername(native(impl), local_endpoint(impl,ec).data(), &len) ); /// The FastCGI check works differently on Windows and UNIX. #if defined(BOOST_WINDOWS) return ( check == SOCKET_ERROR && WSAGetLastError() == WSAENOTCONN ) ? false : true; #else return ( check == -1 && errno == ENOTCONN ) ? false : true; #endif }
ip::udp::socket mikrotik::CreateSocket(boost::asio::io_service &io_service, unsigned short port) { ip::udp::endpoint local_endpoint(ip::udp::v4(), port); ip::udp::socket socket(io_service); socket.open(ip::udp::v4()); socket.set_option(boost::asio::socket_base::broadcast(true)); socket.set_option(boost::asio::socket_base::reuse_address(true)); socket.bind(local_endpoint); return socket; }
socket1.get_option(gettable_socket_option3, ec); socket1.io_control(io_control_command); socket1.io_control(io_control_command, ec); bool non_blocking1 = socket1.non_blocking(); (void)non_blocking1; socket1.non_blocking(true); socket1.non_blocking(false, ec); bool non_blocking2 = socket1.native_non_blocking(); (void)non_blocking2; socket1.native_non_blocking(true); socket1.native_non_blocking(false, ec); ip::udp::endpoint endpoint1 = socket1.local_endpoint(); ip::udp::endpoint endpoint2 = socket1.local_endpoint(ec); ip::udp::endpoint endpoint3 = socket1.remote_endpoint(); ip::udp::endpoint endpoint4 = socket1.remote_endpoint(ec); socket1.shutdown(socket_base::shutdown_both); socket1.shutdown(socket_base::shutdown_both, ec); socket1.wait(socket_base::wait_read); socket1.wait(socket_base::wait_write, ec); socket1.async_wait(socket_base::wait_read, wait_handler()); int i3 = socket1.async_wait(socket_base::wait_write, lazy); (void)i3;
// best effort, if you want to know the error, use // ``local_endpoint(error_code& ec)`` udp::endpoint local_endpoint() const { error_code ec; return local_endpoint(ec); }