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

Next

This commit corrects a missing call to close() against sockfd and add…

…s a missing call to WSACleanup() in the WIN32

case, 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 1572de8e48b444d38ca69f00d4d5f8239e7c069e
@@ -124,8 +124,10 @@ int main(void)
servaddr.sin_port = htons(PORTNUM);

servaddr.sin_addr.s_addr = inet_addr(IPADDR);
if(INADDR_NONE == servaddr.sin_addr.s_addr)
if(INADDR_NONE == servaddr.sin_addr.s_addr) {
close(sockfd);
return 2;
}

if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==
-1) {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.