extract and use common socketConnect method and apply timeout on device connect (potential fix for #594)

This commit is contained in:
John
2022-09-18 12:01:29 +02:00
parent 5eb0a47183
commit cf9d0cc030
6 changed files with 92 additions and 105 deletions
+14
View File
@@ -41,6 +41,20 @@ using std::string;
#endif
#endif
/**
* Connect a TCP or UDP socket.
* @param server the server name or ip address to connect to.
* @param port the port number.
* @param udp true for UDP, false for TCP.
* @param storeAddress optional pointer to where the socket address will be stored.
* @param tcpConnectTimeout the TCP connect timeout in seconds, or 0.
* @param tcpKeepAliveInterval optional interval in seconds for sending TCP keepalive.
* @return the connected socket file descriptor on success, or -1 on error.
*/
int socketConnect(const char* server, uint16_t port, bool udp, socketaddress* storeAddress = nullptr,
int tcpConnectTimeout = 0, int tcpKeepAliveInterval = 0);
/**
* Class for low level TCP socket operations (open, close, send, receive).
*/