win32file.AcceptEx

AcceptEx(sListening, sAccepting, buffer, ol)

Version of accept that uses Overlapped I/O

Parameters

sListening : PySocket /int

Socket that had listen() called on.

sAccepting : PySocket /int

Socket that will be used as the incoming connection.

buffer : buffer

Buffer to read incoming data and connection point information into. This buffer MUST be big enough to recieve your connection endpoints... AF_INET sockets need to be at least 64 bytes. The correct minimum of the buffer is determined by the protocol family that the listening socket is using.

ol : PyOVERLAPPED

An overlapped structure

Comments

In order to make sure the connection has been accepted, either use the hEvent in PyOVERLAPPED, GetOverlappedResult, or GetQueuedCompletionStatus.

To use this with I/O completion ports, don't forget to attach sAccepting to your completion port.

Pass a buffer of exactly the size returned by win32file::CalculateSocketEndPointSize to have AcceptEx return without reading any bytes from the remote connection.

Example

To have sAccepting inherit the properties of sListening, you need to do the following after a connection is successfully accepted

import struct

sAccepting.setsockopt(socket.SOL_SOCKET, win32file.SO_UPDATE_ACCEPT_CONTEXT, struct.pack("I", sListening.fileno()))

Return Value

The result is 0 or ERROR_IO_PENDING. All other values will raise win32file.error. Specifically: if the win32 function returns FALSE, WSAGetLastError() is checked for ERROR_IO_PENDING.