Exemplo n.º 1
0
int handshake(char *hoststr,int portno){
    
   check_endianness(); // check endianness
   int i;

   for(i = 0; i< 10; i++) {
        if ( connection_(hoststr,portno) <0 ) {
           #ifdef STANDALONE  
            printf("connection error...trying again in 3 seconds\n");
          #else
            LOG_E(OMG, " Could not connect to TraCIServer - sleeping before trying again...\n");
         #endif
            sleep(5);
        }
        else {
        #ifdef STANDALONE  
  	  printf(" SUMO now connected to OMG on host address\n");
        #else
          LOG_N(OMG, " SUMO now connected to OMG on host address %s and port %i .\n", hoststr, portno);
	#endif
 	      return 0;  
	}
   }
    #ifdef STANDALONE  
      printf(" SUMO unreachable...giving up...\n"); 
    #else
      LOG_E(OMG, " SUMO unreachable...giving up...\n");
     #endif
    return -1;
}
Exemplo n.º 2
0
 connection_ptr get_connection(resolver_type & resolver, basic_request<Tag> const & request_, optional<string_type> const & certificate_filename = optional<string_type>(), optional<string_type> const & verify_path = optional<string_type>()) {
     string_type protocol_ = protocol(request_);
     connection_ptr connection_(
         new connection_impl(
             follow_redirect_
             , boost::bind(
                 &async_connection_policy<Tag, version_major, version_minor>::resolve,
                 this,
                 _1, _2, _3, _4
                 )
             , resolver
             , boost::iequals(protocol_, string_type("https"))
             , certificate_filename
             , verify_path));
     return connection_;
 }
Exemplo n.º 3
0
 connection_ptr get_connection(resolver_type & resolver, basic_request<Tag> const & request_) {
     connection_ptr connection_(
         new connection_impl(
             resolver
             , follow_redirect_
             , request_.host()
             , lexical_cast<string_type>(request_.port())
             , boost::bind(
                 &simple_connection_policy<Tag,version_major,version_minor>::resolve,
                 this,
                 _1, _2, _3
                 )
             , boost::iequals(request_.protocol(), string_type("https"))
             )
         );
     return connection_;
 }
Exemplo n.º 4
0
 connection_ptr get_connection(
     resolver_type& resolver, basic_request<Tag> const& request_,
     bool always_verify_peer,
     optional<string_type> const& certificate_filename =
         optional<string_type>(),
     optional<string_type> const& verify_path = optional<string_type>(),
     optional<string_type> const& certificate_file = optional<string_type>(),
     optional<string_type> const& private_key_file = optional<string_type>()) {
   string_type protocol_ = protocol(request_);
   connection_ptr connection_(new connection_impl(
       follow_redirect_, always_verify_peer,
       boost::bind(&async_connection_policy<Tag, version_major,
                                            version_minor>::resolve,
                   this, boost::arg<1>(), boost::arg<2>(), boost::arg<3>(),
                   boost::arg<4>()),
       resolver, boost::iequals(protocol_, string_type("https")), timeout_,
       certificate_filename, verify_path, certificate_file, private_key_file));
   return connection_;
 }
Exemplo n.º 5
0
 connection_ptr get_connection(
     resolver_type& resolver, basic_request<Tag> const& request_,
     bool always_verify_peer,
     optional<string_type> /*unused*/ const& certificate_filename =
         optional<string_type>(),
     optional<string_type> const& verify_path = optional<string_type>(),
     optional<string_type> const& certificate_file = optional<string_type>(),
     optional<string_type> const& private_key_file = optional<string_type>(),
     optional<string_type> const& ciphers = optional<string_type>(),
     long ssl_options = 0) {
   namespace ph = std::placeholders;
   connection_ptr connection_(new connection_impl(
       resolver, follow_redirect_, always_verify_peer, request_.host(),
       std::to_string(request_.port()),
       [this](resolver_type& resolver, string_type const& host,
              std::uint16_t port, resolver_completion_function once_resolved) {
         this->resolve(resolver, host, port, once_resolved);
       },
       boost::iequals(request_.protocol(), string_type("https")), timeout_,
       certificate_filename, verify_path, certificate_file, private_key_file,
       ciphers, ssl_options));
   return connection_;
 }