Wsacleanup

This is a discussion on Wsacleanup within the Networking/Device Communication forums, part of the General Programming Boards category; Hi. I saw a tutorial that called WSACleanup(), every time an error occured. In a larger app, is this really ...

  1. #1
    Registered User Drogin's Avatar
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    105

    Wsacleanup

    Hi.
    I saw a tutorial that called WSACleanup(), every time an error occured.

    In a larger app, is this really necceceary? Isnt it good enough to just call closesocket(), on the socket which caused the error, and go over again?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    WSACleanup() should be called when your application is done using sockets.

  3. #3
    Registered User Drogin's Avatar
    Join Date
    Oct 2005
    Location
    Norway
    Posts
    105
    ..Well, my app won't stop using sockets untill it ends...
    Is this a good solution?

    In winmain():
    Code:
     
    WSAStartup(); // Can't actually remember the exact function name..

    In MessageProcedure:
    Code:
    case WM_DESTROY:
    WSACleanup();
    return 0;

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Yeah, that works.

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    14
    On a related note, can I use
    Code:
      atexit(WSACleanup());
    and is that a reliable solution, or should I really just make sure I do it all manually. I know that in many cases, atexit() is frowned upon, but I'm not really sure why... any reasons?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Send/Recv
    By brietje698 in forum Networking/Device Communication
    Replies: 13
    Last Post: 12-13-2007, 09:16 PM
  2. c++ networking
    By ThinkGeekness in forum Networking/Device Communication
    Replies: 10
    Last Post: 08-03-2005, 02:55 PM
  3. Unresolved External Error (WSAStartup, WSACleanup)
    By Epo in forum Networking/Device Communication
    Replies: 1
    Last Post: 01-16-2004, 11:58 PM
  4. help with netcode!
    By sargas99 in forum Game Programming
    Replies: 1
    Last Post: 09-15-2002, 09:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21