1.配置默认使用v3。2.asio中文转u8。3.com*hpp添加一个trim功能。
This commit is contained in:
		
							parent
							
								
									f99b2cbabb
								
							
						
					
					
						commit
						2847a88525
					
				
							
								
								
									
										17
									
								
								server.cxx
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								server.cxx
									
									
									
									
									
								
							@ -14,6 +14,15 @@ Server::~Server()
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Server::print_exception(const std::exception& e)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#ifdef _WIN32
 | 
				
			||||||
 | 
					    std::cerr << ansi_to_u8(e.what()) << '\n';
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    std::cerr << e.what() << '\n';
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Server::start()
 | 
					void Server::start()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), port_);
 | 
					    asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), port_);
 | 
				
			||||||
@ -24,11 +33,7 @@ void Server::start()
 | 
				
			|||||||
        acceptor_.listen();
 | 
					        acceptor_.listen();
 | 
				
			||||||
        do_accept();
 | 
					        do_accept();
 | 
				
			||||||
    } catch (const std::exception& e) {
 | 
					    } catch (const std::exception& e) {
 | 
				
			||||||
#ifdef _WIN32
 | 
					        print_exception(e);
 | 
				
			||||||
        std::cerr << ansi_to_u8(e.what()) << '\n';
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
        std::cerr << e.what() << '\n';
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -159,4 +164,4 @@ bool Server::send_frame(const std::shared_ptr<asio::ip::tcp::socket>& socket, Fr
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    delete[] send_data;
 | 
					    delete[] send_data;
 | 
				
			||||||
    return send_len == len;
 | 
					    return send_len == len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										1
									
								
								server.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								server.h
									
									
									
									
									
								
							@ -34,6 +34,7 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    std::string post_data(const std::string& data);
 | 
					    std::string post_data(const std::string& data);
 | 
				
			||||||
    bool send_frame(const std::shared_ptr<asio::ip::tcp::socket>& socket, FrameData& data);
 | 
					    bool send_frame(const std::shared_ptr<asio::ip::tcp::socket>& socket, FrameData& data);
 | 
				
			||||||
 | 
					    void print_exception(const std::exception& e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    asio::io_context& io_context_;
 | 
					    asio::io_context& io_context_;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user