This method is used to attach a socket handle created outside of
the class using the SocketWrench API. Once the socket handle is
attached to the class, the other class member functions may be used
with that socket. If the socket was created by a third-party library
or the Windows Sockets API, then the handle will be automatically
inherited by the library.
If a socket handle already has been created for the class, that
handle will be released when the new handle is attached to the class
object. If you want to prevent the previous socket connection from
being terminated, you must call the DetachHandle method.
Failure to release the detached handle may result in a resource leak
in your application.
If the dwProcessId parameter specifies another process, the
socket will be duplicated into the current process, attached to the
current thread and the original socket handle will be closed in the
other process. This enables an application to effectively take
control of a connection created by another process. The original
socket handle must be inheritable by the by the current process and
must be an actual Windows socket handle, not a pseudo-handle. This
functionality is only supported on Windows NT 4.0 and later versions
of the operating system with the Microsoft TCP/IP stack. Note that
Layered Service Providers (LSPs) may interfere with the ability to
inherit handles across processes.
If the socket was created by another process, it is initialized by
the library in a blocking state, even if was originally using
asynchronous socket events. If the application requires that the
socket use events, it must explicitly call EnableEvents. A
program should never try to attach to a secure connection created by
another process because the attached socket will not have the
security context required to encrypt and decrypt the data exchanged
with the remote host.