| |
| BOOL Accept( |
| |
SOCKET hSocket, |
|
| |
UINT nTimeout, |
|
| |
DWORD dwOptions |
|
| ); |
| BOOL Accept( |
| |
CSocketWrench&
swServer, |
|
| |
UINT nTimeout, |
|
| |
DWORD dwOptions |
|
| ); |
The Accept method is used to accept a pending client
connection.
This method has been deprecated and is included for
backwards compatibility. Use the CInternetServer
class to create a server application.
Parameters
- hSocket
- Handle to the listening socket. This argument may also
reference a CSocketWrench object which is listening for
connections. In either case, the server socket must have been
created by calling the Listen method.
- nTimeout
- The number of seconds that the server will wait for a client
connection before failing the operation. This value is used only
for blocking connections.
- dwOptions
- An unsigned integer that specifies one or more options. This
parameter is constructed by using a bitwise operator with any of
the following values:
| Value |
Description |
| INET_OPTION_KEEPALIVE |
This option specifies that packets are to be sent to the
remote system when no data is being exchanged to keep the
connection active. This is only valid for stream sockets. |
| INET_OPTION_REUSEADDRESS |
This option specifies the local address can be reused.
This option is commonly used by server applications. |
| INET_OPTION_NODELAY |
This option disables the Nagle algorithm, which buffers
unacknowledged data and insures that a full-size packet can be
sent to the remote host. |
| INET_OPTION_INLINE |
This option controls how urgent (out-of-band) data is
handled when reading data from the socket. If set, urgent data
is placed in the data stream along with non-urgent data. |
| INET_OPTION_NOINHERIT |
This option prevents the socket handle from being inherited
by child processes created by the application. Using this option
can mitigate situations in which a child process does not close
the handle, leaving it open after the parent process has
stopped the server. |
| INET_OPTION_TRUSTEDSITE |
This option specifies the server is trusted. The server
certificate will not be validated and the connection will always
be permitted. This option only affects connections using either
the TLS protocol. |
| INET_OPTION_SECURE |
This option determines if a secure connection is
established with the remote host. |
| INET_OPTION_SECURE_FALLBACK |
This option specifies the server should permit the use
of less secure cipher suites for compatibility with legacy
clients. If this option is specified, the server will allow
connections using TLS 1.0 and cipher suites that use RC4, MD5
and SHA1. |
| INET_OPTION_FREETHREAD |
This option specifies that this instance of the class may
be used by any thread, and is not limited to the thread which
created it. The application is responsible for ensuring that
access to the class instance is synchronized across multiple
threads. |
Return Value
If the method succeeds, the return value is non-zero. If the
method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
When a connection is accepted by the server, the original
listening socket continues to listen for more connections. If no
event notification window is specified, then Accept will block
until a client attempts to connect to the server or the timeout
period expires.
The dwOptions argument can be used to specify the threading
model that is used by the library when a connection is established.
By default, the class instance is initially attached to the thread
that created it. From that point on, until the handle is released, only
the owner may call methods using that instance of the class. The
ownership of the class instance may be transferred from one thread to
another using the AttachThread method.
Specifying the INET_OPTION_FREETHREAD option enables any thread to
call any method in that instance of the class, regardless of which
thread created it. It is important to note that this option disables
certain internal safety checks which are performed by the library and
may result in unexpected behavior unless access to the class instance
is synchronized. If one thread calls a function in the library, it
must ensure that no other thread will call another function at the
same time using the same instance.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cswsock11.h
Import Library: cswskv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
Accept,
Connect,
Disconnect,
Listen
|
|