Thread: Wsacleanup

  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,268
    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,268
    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, 10: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-17-2004, 12:58 AM
  4. help with netcode!
    By sargas99 in forum Game Programming
    Replies: 1
    Last Post: 09-15-2002, 09:39 AM