51d1bcdbeac4b2ee7ce4d749c2a975e8bd8a72b1 galt Wed May 27 18:34:11 2020 -0700 added -timeout=1 and -host=blat1a options diff --git src/inc/net.h src/inc/net.h index e24ba07..162b546 100644 --- src/inc/net.h +++ src/inc/net.h @@ -12,30 +12,36 @@ #include "internet.h" #define DEFAULTCONNECTTIMEOUTMSEC 10000 /* default connect timeout for tcp in milliseconds */ #define DEFAULTREADWRITETTIMEOUTSEC 120 /* default read/write timeout for tcp in seconds */ #define MAXURLSIZE 4096 /* maximum size in characters for a URL, but also see the struct netParsedUrl definition */ int setReadWriteTimeouts(int sd, int seconds); /* Set read and write timeouts on socket sd * Return -1 if there are any errors, 0 if successful. */ /* add a failure to connFailures[] * which can save time and avoid more timeouts */ int netConnect(char *hostName, int port); /* Start connection with a server having resolved port. Return < 0 if error. */ +int netConnectWithTimeout(char *hostName, int port, long msTimeout); +/* In order to avoid a very long default timeout (several minutes) for hosts that will +* not answer the port, we are forced to connect non-blocking. +* After the connection has been established, we return to blocking mode. +* Also closes sd if error. */ + int netMustConnect(char *hostName, int port); /* Start connection with server or die. */ int netMustConnectTo(char *hostName, char *portName); /* Start connection with a server and a port that needs to be converted to integer */ int netAcceptingSocket(int port, int queueSize); /* Create an IPV6 socket that can accept connections from * both IPV4 and IPV6 clients on the current machine. */ int netAccept(int sd); /* Accept incoming connection from socket descriptor. */ int netAcceptFrom(int acceptor, struct cidr *subnet); /* Wait for incoming connection from socket descriptor