当前位置: 首页>>代码示例>>C++>>正文


C++ socket_type类代码示例

本文整理汇总了C++中socket_type的典型用法代码示例。如果您正苦于以下问题:C++ socket_type类的具体用法?C++ socket_type怎么用?C++ socket_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了socket_type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process

void run_server::process(socket_type ssock,
                         pfi::lang::shared_ptr<cgi> cc)
{
  for (;;){
    pfi::lang::shared_ptr<stream_socket> sock(ssock->accept());
    if (!sock) continue;

    if (ssock->timeout()>0 && !sock->set_timeout(ssock->timeout()))
      continue;

    try{
      http::request req(sock);
      stringstream sout;

      map<string, string> env;

      for (http::header::iterator p=req.head().begin();
           p!=req.head().end(); p++)
        env["HTTP_"+str_to_upper(p->first)]=p->second;

      env["REQUEST_METHOD"]=req.method();
      env["REQUEST_URI"]=req.path().path();
      if (req.path().query()!="")
        env["REQUEST_URI"]+="?"+req.path().query();
      env["SCRIPT_NAME"]=req.path().path();
      env["QUERY_STRING"]=req.path().query();

      env["REMOTE_ADDR"]=sock->remote_addr().to_string();
      env["REMOTE_PORT"]=lexical_cast<string>(sock->remote_port());

      env["SERVER_PORT"]=lexical_cast<string>(ssock->port());
      env["SERVER_NAME"]="localhost";
      env["SERVER_PROTOCOL"]="HTTP/1.1";
      env["SERVER_SIGNATURE"]="pficommon/" PFICOMMON_VERSION " standalone web server";
      env["SERVER_SOFTWARE"]="pficommon/" PFICOMMON_VERSION;

      env["CONTENT_LENGTH"]=req.head()["Content-Length"];
      env["CONTENT_TYPE"]=req.head()["Content-Type"];

      cc->exec(req.body(), sout, cerr, env);

      pfi::lang::shared_ptr<http::response> resp=gen_resp(sout);
      resp->send(sock);
    }
    catch(exception&){
    }
  }
}
开发者ID:b-xiang,项目名称:pficommon,代码行数:48,代码来源:server.cpp

示例2: lambda

 lambda(int id_, http_sync_server& self_,
         socket_type&& sock_)
     : id(id_)
     , self(self_)
     , sock(std::move(sock_))
     , work(sock.get_io_service())
 {
 }
开发者ID:andyzhshg,项目名称:rippled,代码行数:8,代码来源:http_sync_server.hpp

示例3: resize_buffs

 static void resize_buffs(socket_type sock, const size_t rx_size, const size_t tx_size){
     if (rx_size != 0) sock->set_option(asio::socket_base::receive_buffer_size(rx_size));
     if (tx_size != 0) sock->set_option(asio::socket_base::send_buffer_size(tx_size));
 }
开发者ID:dkozel,项目名称:uhd,代码行数:4,代码来源:network_relay.cpp

示例4: close

    void close()
    {
        boost::system::error_code ignored_ec;

        m_socket.shutdown(
            boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);

        m_socket.close(ignored_ec);
    }
开发者ID:chronolaw,项目名称:professional_boost,代码行数:9,代码来源:tcp_session.hpp

示例5: write

 void write()
 {
     m_socket.async_write_some(
             m_write_buf.data(),
             bind(&this_type::handle_write, shared_from_this(),
                 boost::asio::placeholders::error,
                 boost::asio::placeholders::bytes_transferred)
             );
 }
开发者ID:chronolaw,项目名称:professional_boost,代码行数:9,代码来源:tcp_session.hpp

示例6: read

 void read()
 {
     m_socket.async_read_some(
             m_read_buf.prepare(),
             bind(&this_type::handle_read, shared_from_this(),
                 boost::asio::placeholders::error,
                 boost::asio::placeholders::bytes_transferred)
             );
 }
开发者ID:chronolaw,项目名称:professional_boost,代码行数:9,代码来源:tcp_session.hpp

示例7: Request

        Request (CheckerImp& owner, boost::asio::io_service& io_service,
            IP::Endpoint const& address, asio::shared_handler <
                void (Result)> const& handler)
            : m_owner (owner)
            , m_io_service (io_service)
            , m_address (address)
            , m_handler (handler)
            , m_socket (m_io_service)
            , m_canAccept (false)
        {
            m_owner.add (*this);

            m_socket.async_connect (IPAddressConversion::to_asio_endpoint (
                m_address), asio::wrap_handler (std::bind (
                    &Request::handle_connect, Ptr(this),
                        asio::placeholders::error), m_handler));
        }
开发者ID:Blizzard-,项目名称:rippled,代码行数:17,代码来源:Checker.cpp

示例8: receive_one_from_socket_into_queue

    /// Try receive one packet from the socket into the incoming_queue
    bool receive_one_from_socket_into_queue()
    {
        bool r=false;
        // Is there space to receive a packet?
        if( incoming_not_full() )
        {
            // Yes, try receive a packet into the queue
            if( m_sock->recv(incoming_queue().incoming()) >= 0 )
            {
                // Got one! push it into the incoming queue
                incoming_queue().push();

                // and show success
                r = true;
            }
        }
        return r;
    }
开发者ID:ThomasSchaeferMS,项目名称:Obbligato,代码行数:19,代码来源:Net_QueuedSocket.hpp

示例9: send_one_from_queue_to_socket

    /// Send one packet from the outgoing_queue out the socket
    bool send_one_from_queue_to_socket()
    {
        bool r=false;
        // Is there a packet to send?
        if( outgoing_not_empty() )
        {
            // Yes, try send it
            if( m_sock->send(outgoing_queue().outgoing()) >= 0 )
            {
                // Success sending it, so pop the packet off the outgoing queue
                outgoing_queue().pop();

                // and show success
                r=true;
            }
        }
        return r;
    }
开发者ID:ThomasSchaeferMS,项目名称:Obbligato,代码行数:19,代码来源:Net_QueuedSocket.hpp

示例10: do_write_some

	size_t do_write_some(const const_buffer &buffers, error_code &ec)
	{
		return socket.write_some(buffers, ec);		
	}
开发者ID:mnemonicflow,项目名称:boost-httpclient,代码行数:4,代码来源:http_connection.hpp

示例11: do_read_some

	size_t do_read_some(const mutable_buffer &buffers, error_code &ec)
	{
		return socket.read_some(buffers, ec);	
	}
开发者ID:mnemonicflow,项目名称:boost-httpclient,代码行数:4,代码来源:http_connection.hpp

示例12:

	lowest_layer_type& do_lowest_layer()
	{
		return socket.lowest_layer();	
	}
开发者ID:mnemonicflow,项目名称:boost-httpclient,代码行数:4,代码来源:http_connection.hpp

示例13: do_async_write_some

	void do_async_write_some(const const_buffer &buffers, WriteHandler handler)
	{
		socket.async_write_some(buffers, handler);		
	}
开发者ID:mnemonicflow,项目名称:boost-httpclient,代码行数:4,代码来源:http_connection.hpp

示例14: do_async_read_some

	void do_async_read_some(const mutable_buffer &buffers, ReadHandler handler)
	{
		socket.async_read_some(buffers, handler);		
	}
开发者ID:mnemonicflow,项目名称:boost-httpclient,代码行数:4,代码来源:http_connection.hpp

示例15:

 ios_type& io_service()
 {   return m_socket.get_io_service();}
开发者ID:chronolaw,项目名称:professional_boost,代码行数:2,代码来源:tcp_session.hpp


注:本文中的socket_type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。