int check_for_waiting_request(implementation_type& impl
                                   , CommonGatewayRequest& request
                                   , Handler handler)
     {
       // We can't call accept on an open request (close it first).
       if (request.is_open())
         return handler(error::accepting_on_an_open_request);

       // If the client is open, make sure the request is clean.
       // ie. don't leak data from one request to another!
       if (request.client().is_open())
       {
         request.clear();
       }

       // If we can reuse this request's connection, return.
       if (request.client().keep_connection())
         return handler(boost::system::error_code());

       // ...otherwise accept a new connection.
       if (transport_ == detail::transport::pipe)
       {
         boost::system::error_code ec;
         detail::accept_named_pipe(listen_handle_, *request.client().connection(), ec);
         strand_.post(handler);
       }
       else // transport_ == detail::transport::socket
       {
           acceptor_service_.async_accept(impl.acceptor_, *request.client().connection()->socket_, impl.endpoint_, handler);
       }

       return 0;
     }
     boost::system::error_code
       accept(implementation_type& impl, CommonGatewayRequest& request
             , endpoint_type* endpoint, boost::system::error_code& ec)
     {
       BOOST_ASSERT
       ( ! request.is_open()
        && "Error: Calling accept on open request (close it first?)."
       );

       // If the client is open, make sure the request is clean.
       // ie. don't leak data from one request to another!
       if (request.client().is_open())
       {
         request.clear();
       }

       // If we can reuse this request's connection, return.
       if (request.client().keep_connection())
         return ec;

       if (transport_ == detail::transport::pipe)
         detail::accept_named_pipe(listen_handle_, *request.client().connection(), ec);
       else // transport_ == detail::transport::socket
         acceptor_service_.accept(impl.acceptor_, *new_request->client().connection()->socket_, &impl.endpoint_, ec);

       if (!ec)
         request.status(common::accepted);
       return ec;
     }
Esempio n. 3
0
    boost::system::error_code
    accept(implementation_type& impl, CommonGatewayRequest& request
           , endpoint_type* endpoint, boost::system::error_code& ec)
    {
        BOOST_ASSERT
        ( ! request.is_open()
          && "Error: Calling accept on open request (close it first?)."
        );

        // If the client is open, make sure the request is clean.
        // ie. don't leak data from one request to another!
        if (request.client().is_open())
        {
            request.clear();
        }

        // If we can reuse this request's connection, return.
        if (request.client().keep_connection())
            return ec;

        // ...otherwise accept a new connection.
        ec = acceptor_service_.accept(impl.acceptor_,
                                      *request.client().connection()->socket_, endpoint, ec);
        if (!ec)
            request.status(common::accepted);
        return ec;
    }
Esempio n. 4
0
    int check_for_waiting_request(implementation_type& impl
                                  , CommonGatewayRequest& request
                                  , Handler handler)
    {
        // We can't call accept on an open request (close it first).
        if (request.is_open())
            return handler(error::accepting_on_an_open_request);

        // If the client is open, make sure the request is clean.
        // ie. don't leak data from one request to another!
        if (request.client().is_open())
        {
            request.clear();
        }

        // If we can reuse this request's connection, return.
        if (request.client().keep_connection())
            return handler(boost::system::error_code());

        // ...otherwise accept a new connection (asynchronously).
        acceptor_service_.async_accept(impl.acceptor_,
                                       *request.client().connection()->socket_, 0, handler);
        return 0;
    }