| 2827 | } |
| 2828 | |
| 2829 | static rem_port* inet_try_connect(PACKET* packet, |
| 2830 | Rdb* rdb, |
| 2831 | const PathName& file_name, |
| 2832 | const TEXT* node_name, |
| 2833 | ClumpletReader& dpb, |
| 2834 | RefPtr<const Config>* config, |
| 2835 | const PathName* ref_db_name, |
| 2836 | int af) |
| 2837 | { |
| 2838 | /************************************** |
| 2839 | * |
| 2840 | * i n e t _ t r y _ c o n n e c t |
| 2841 | * |
| 2842 | ************************************** |
| 2843 | * |
| 2844 | * Functional description |
| 2845 | * Given a packet with formatted protocol infomation, |
| 2846 | * set header information and try the connection. |
| 2847 | * |
| 2848 | * If a connection is established, return a port block, otherwise |
| 2849 | * return NULL. |
| 2850 | * |
| 2851 | **************************************/ |
| 2852 | P_CNCT* cnct = &packet->p_cnct; |
| 2853 | packet->p_operation = op_connect; |
| 2854 | cnct->p_cnct_operation = 0; |
| 2855 | cnct->p_cnct_cversion = CONNECT_VERSION3; |
| 2856 | cnct->p_cnct_client = ARCHITECTURE; |
| 2857 | |
| 2858 | const PathName& cnct_file(ref_db_name ? (*ref_db_name) : file_name); |
| 2859 | cnct->p_cnct_file.cstr_length = (ULONG) cnct_file.length(); |
| 2860 | cnct->p_cnct_file.cstr_address = reinterpret_cast<const UCHAR*>(cnct_file.c_str()); |
| 2861 | |
| 2862 | // If we can't talk to a server, punt. Let somebody else generate |
| 2863 | // an error. status_vector will have the network error info. |
| 2864 | |
| 2865 | rem_port* port = NULL; |
| 2866 | try |
| 2867 | { |
| 2868 | port = INET_connect(node_name, packet, false, &dpb, config, af); |
| 2869 | } |
| 2870 | catch (const Exception&) |
| 2871 | { |
| 2872 | delete rdb; |
| 2873 | throw; |
| 2874 | } |
| 2875 | |
| 2876 | // Get response packet from server. |
| 2877 | |
| 2878 | rdb->rdb_port = port; |
| 2879 | port->port_context = rdb; |
| 2880 | if (!port->receive(packet)) |
| 2881 | { |
| 2882 | rdb->rdb_port = NULL; |
| 2883 | delete rdb; |
| 2884 | inet_error(true, port, "receive in try_connect", isc_net_connect_err, INET_ERRNO); |
| 2885 | } |
| 2886 |
no test coverage detected