From bcfb9ea34cc7cddbbf74376aa16043681e4745a7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 18 Dec 2010 17:12:44 +0100 Subject: examples: socket type cleanup --- docs/examples/sendrecv.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'docs/examples/sendrecv.c') diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c index ad5ddd115..499fadb92 100644 --- a/docs/examples/sendrecv.c +++ b/docs/examples/sendrecv.c @@ -14,7 +14,7 @@ #include /* Auxiliary function that waits on the socket. */ -static int wait_on_socket(int sockfd, int for_recv, long timeout_ms) +static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms) { struct timeval tv; fd_set infd, outfd, errfd; @@ -49,7 +49,8 @@ int main(void) CURLcode res; /* Minimalistic http request */ const char *request = "GET / HTTP/1.0\r\nHost: example.com\r\n\r\n"; - int sockfd; /* socket */ + curl_socket_t sockfd; /* socket */ + long sockextr; size_t iolen; curl = curl_easy_init(); @@ -65,9 +66,11 @@ int main(void) return 1; } - /* Extract the socket from the curl handle - we'll need it - * for waiting */ - res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd); + /* Extract the socket from the curl handle - we'll need it for waiting. + * Note that this API takes a pointer to a 'long' while we use + * curl_socket_t for sockets otherwise. + */ + res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockextr); if(CURLE_OK != res) { @@ -75,6 +78,8 @@ int main(void) return 1; } + sockfd = sockextr; + /* wait for the socket to become ready for sending */ if(!wait_on_socket(sockfd, 0, 60000L)) { -- cgit v1.2.3