| 860 | } |
| 861 | |
| 862 | rem_port* INET_connect(const TEXT* name, |
| 863 | PACKET* packet, |
| 864 | USHORT flag, |
| 865 | ClumpletReader* dpb, |
| 866 | RefPtr<const Config>* config, |
| 867 | int af) |
| 868 | { |
| 869 | /************************************** |
| 870 | * |
| 871 | * I N E T _ c o n n e c t |
| 872 | * |
| 873 | ************************************** |
| 874 | * |
| 875 | * Functional description |
| 876 | * Establish half of a communication link. If a connect packet is given, |
| 877 | * the connection is on behalf of a remote interface. Otherwise the connect |
| 878 | * is for a server process. |
| 879 | * |
| 880 | **************************************/ |
| 881 | #ifdef DEBUG |
| 882 | { |
| 883 | if (INET_trace & TRACE_operations) |
| 884 | { |
| 885 | fprintf(stdout, "INET_connect\n"); |
| 886 | fflush(stdout); |
| 887 | } |
| 888 | INET_start_time = inet_debug_timer(); |
| 889 | // CVC: I don't see the point in replacing this with fb_utils::readenv(). |
| 890 | const char* p = getenv("INET_force_error"); |
| 891 | if (p != NULL) { |
| 892 | INET_force_error = atoi(p); |
| 893 | } |
| 894 | } |
| 895 | #endif |
| 896 | |
| 897 | rem_port* port = alloc_port(NULL); |
| 898 | if (config) |
| 899 | { |
| 900 | port->port_config = *config; |
| 901 | } |
| 902 | REMOTE_get_timeout_params(port, dpb); |
| 903 | |
| 904 | string host; |
| 905 | string protocol; |
| 906 | |
| 907 | if ((!name || !name[0]) && !packet) |
| 908 | { |
| 909 | name = port->getPortConfig()->getRemoteBindAddress(); |
| 910 | } |
| 911 | |
| 912 | if (name) |
| 913 | { |
| 914 | host = name; |
| 915 | const FB_SIZE_T pos = host.find("/"); |
| 916 | |
| 917 | if (pos != string::npos) |
| 918 | { |
| 919 | protocol = host.substr(pos + 1); |
no test coverage detected