|
WSACleanup
The Windows Sockets WSACleanup function terminates use of the Windows Sockets DLL.
int WSACleanup (void);
Remarks
An application or DLL is required to perform a successful WSAStartup call before it can use Windows Sockets services. When it has completed the
use of Windows Sockets, the application or DLL must call WSACleanup to deregister itself from a Windows Sockets implementation and allow the
implementation to free any resources allocated on behalf of the application or DLL.
Any pending blocking or asynchronous calls issued by any thread in this
process are canceled without posting any notification messages, or signaling any
event objects. Any pending overlapped send and receive operations (WSASend/WSASendTo/WSARecv/WSARecvFrom with an overlapped socket) issued by any thread in this process are also
canceled without setting the event object or invoking the completion routine, if
specified. In this case, the pending overlapped operations fail with the error
status WSA_OPERATION_ABORTED. Any sockets open when WSACleanup is called are reset and automatically deallocated as if closesocket was called; sockets which have been closed with closesocket but which still have pending data to be sent may be affected the pending data may be lost if the Windows Sockets DLL is unloaded from
memory as the application exits. To insure that all pending data is sent an
application should use shutdown to close the connection, then wait until the close completes before calling closesocket and WSACleanup. All resources and internal state, such as queued un-posted messages, must be
deallocated so as to be available to the next user.
There must be a call to WSACleanup for every successful call to WSAStartup made by a task. Only the final WSACleanup for that task does the actual cleanup; the preceding calls simply decrement
an internal reference count in the Windows Sockets DLL.
Return Values
The return value is zero if the operation was successful. Otherwise, the value
SOCKET_ERROR is returned, and a specific error number may be retrieved by
calling WSAGetLastError.
Comments
Attempting to call WSACleanup from within a blocking hook and then failing to check the return code is a
common Windows Sockets programming error. If an application needs to quit while a
blocking call is outstanding, the application must first cancel the blocking
call with WSACancelBlockingCall then issue the WSACleanup call once control has been returned to the application.
In a multithreaded environment, WSACleanup terminates Windows Sockets operations for all threads.
Error Codes
WSANOTINITIALISED
| A successful WSAStartup must occur before using this function.
| WSAENETDOWN
| The network subsystem has failed.
| WSAEINPROGRESS
| A blocking Windows Sockets 1.1 call is in progress, or the service provider is
still processing a callback function.
|
See Also
closesocket, shutdown, WSAStartup
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|