Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket handling and WIN32 WSACleanup fixes #3663

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add missing WSACleanup() call, per Microsoft's Winsock2 documentation:

   https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-wsacleanup

WSACleanup() should ideally be called before any return from main() that occurs after the call to WSAStartup().
  • Loading branch information...
Andre Guibert de Bruet
Andre Guibert de Bruet committed Mar 11, 2019
commit 943fb74dfe8b0236d5a37453a9a03a79667866d0
@@ -159,10 +159,16 @@ int main(void)

curl_easy_cleanup(curl);

close(sockfd);
This conversation was marked as resolved by andyguibert

This comment has been minimized.

Copy link
@jay

jay Mar 11, 2019

Member

easy cleanup closes the socket, i believe that happens in all cases

This comment has been minimized.

Copy link
@bagder

bagder Mar 11, 2019

Member

Well, then the close callback gets called since CURLOPT_CLOSESOCKETFUNCTION is used by the example, which (for some reason) doesn't close the socket! So I think adding a close is ok.

But doesn't windows use closesocket() for this?

This comment has been minimized.

Copy link
@jay

jay Mar 11, 2019

Member

Well, then the close callback gets called since CURLOPT_CLOSESOCKETFUNCTION is used by the example, which (for some reason) doesn't close the socket! So I think adding a close is ok.

ah ok. maybe that makes more sense since it's opened externally.

But doesn't windows use closesocket() for this?

close maps to closesocket in the example so it's fine.


if(res) {
printf("libcurl error: %d\n", res);
return 4;
}
}

#ifdef WIN32
WSACleanup();
#endif
return 0;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.