summaryrefslogtreecommitdiff
path: root/lib/connect.h
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-12-05 10:58:38 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-12-05 10:58:38 +0100
commit9109cdec11ee5a19f132fd7bdf2e9ceefea4de41 (patch)
tree796ebc5b439951510717c914c57af65360da2af5 /lib/connect.h
parent5971d401d4fd184aedd3b439251a898ecdacb96e (diff)
downloadcurl-9109cdec11ee5a19f132fd7bdf2e9ceefea4de41.tar.gz
Curl_socket: internal replacement for socket()
Moved out into a separate function to work as a "generic" socket() replacement.
Diffstat (limited to 'lib/connect.h')
-rw-r--r--lib/connect.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/connect.h b/lib/connect.h
index 052549368..f84361f2e 100644
--- a/lib/connect.h
+++ b/lib/connect.h
@@ -24,6 +24,7 @@
#include "setup.h"
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
+#include "sockaddr.h"
CURLcode Curl_is_connected(struct connectdata *conn,
int sockindex,
@@ -72,4 +73,35 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd);
void Curl_persistconninfo(struct connectdata *conn);
int Curl_closesocket(struct connectdata *conn, curl_socket_t sock);
+/*
+ * The Curl_sockaddr_ex structure is basically libcurl's external API
+ * curl_sockaddr structure with enough space available to directly hold any
+ * protocol-specific address structures. The variable declared here will be
+ * used to pass / receive data to/from the fopensocket callback if this has
+ * been set, before that, it is initialized from parameters.
+ */
+struct Curl_sockaddr_ex {
+ int family;
+ int socktype;
+ int protocol;
+ unsigned int addrlen;
+ union {
+ struct sockaddr addr;
+ struct Curl_sockaddr_storage buff;
+ } _sa_ex_u;
+};
+#define sa_addr _sa_ex_u.addr
+
+/*
+ * Create a socket based on info from 'conn' and 'ai'.
+ *
+ * Fill in 'addr' and 'sockfd' accordingly if OK is returned. If the open
+ * socket callback is set, used that!
+ *
+ */
+CURLcode Curl_socket(struct connectdata *conn,
+ const Curl_addrinfo *ai,
+ struct Curl_sockaddr_ex *addr,
+ curl_socket_t *sockfd);
+
#endif /* HEADER_CURL_CONNECT_H */